From 95f22bc07bfc26c7562bd349d5535fd41b3d7d07 Mon Sep 17 00:00:00 2001 From: Kai Xia Date: Wed, 25 Feb 2026 20:43:45 +1100 Subject: [PATCH] enable bodyclose Checks whether HTTP response body is closed successfully. Signed-off-by: Kai Xia --- .golangci.yaml | 1 - pkg/channels/onebot.go | 5 ++++- pkg/channels/whatsapp.go | 5 ++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index dd3cbae19..36b8c2832 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -28,7 +28,6 @@ linters: - wsl_v5 # TODO: Disabled, because they are failing at the moment, we should fix them and enable (step by step) - - bodyclose - contextcheck - dogsled - embeddedstructfieldcheck diff --git a/pkg/channels/onebot.go b/pkg/channels/onebot.go index cee8ad9d3..3e26ec943 100644 --- a/pkg/channels/onebot.go +++ b/pkg/channels/onebot.go @@ -174,7 +174,10 @@ func (c *OneBotChannel) connect() error { header["Authorization"] = []string{"Bearer " + c.config.AccessToken} } - conn, _, err := dialer.Dial(c.config.WSUrl, header) + conn, resp, err := dialer.Dial(c.config.WSUrl, header) + if resp != nil { + resp.Body.Close() + } if err != nil { return err } diff --git a/pkg/channels/whatsapp.go b/pkg/channels/whatsapp.go index 958d850bb..2dc4017ac 100644 --- a/pkg/channels/whatsapp.go +++ b/pkg/channels/whatsapp.go @@ -41,7 +41,10 @@ func (c *WhatsAppChannel) Start(ctx context.Context) error { dialer := websocket.DefaultDialer dialer.HandshakeTimeout = 10 * time.Second - conn, _, err := dialer.Dial(c.url, nil) + conn, resp, err := dialer.Dial(c.url, nil) + if resp != nil { + resp.Body.Close() + } if err != nil { return fmt.Errorf("failed to connect to WhatsApp bridge: %w", err) }