From c703ac6805bbb90d7f8b6b79bdc6d294c102d26d Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Fri, 2 Sep 2022 12:25:51 +0300 Subject: [PATCH] golangci: enable contextcheck linter, fix WSClient pkg/rpcclient/wsclient.go:93:30 contextcheck Function `Dial` should pass the context parameter --- .golangci.yml | 1 + pkg/rpcclient/wsclient.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.golangci.yml b/.golangci.yml index 2fed511a0..b35bc5bd3 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -43,6 +43,7 @@ linters: # extra linters # - exhaustive - bodyclose + - contextcheck - gofmt - whitespace - goimports diff --git a/pkg/rpcclient/wsclient.go b/pkg/rpcclient/wsclient.go index d1284716b..3a71d8bb9 100644 --- a/pkg/rpcclient/wsclient.go +++ b/pkg/rpcclient/wsclient.go @@ -90,7 +90,7 @@ var errConnClosedByUser = errors.New("connection closed by user") // operating on. func NewWS(ctx context.Context, endpoint string, opts Options) (*WSClient, error) { dialer := websocket.Dialer{HandshakeTimeout: opts.DialTimeout} - ws, resp, err := dialer.Dial(endpoint, nil) + ws, resp, err := dialer.DialContext(ctx, endpoint, nil) if resp != nil && resp.Body != nil { // Can be non-nil even with error returned. defer resp.Body.Close() // Not exactly required by websocket, but let's do this for bodyclose checker. }