Skip to content

Commit

Permalink
use bodyclose linter and fix errors it reports (#389)
Browse files Browse the repository at this point in the history
  • Loading branch information
cosnicolaou authored Apr 17, 2023
1 parent 0a638ba commit e03230a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ linters-settings:

linters:
enable:
- bodyclose
- gocritic
- gocyclo
- gofmt
Expand Down
15 changes: 10 additions & 5 deletions x/ref/runtime/protocols/lib/websocket/ws.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@ import (
"net/url"
"time"

"v.io/x/ref/runtime/protocols/lib/tcputil"

"github.com/gorilla/websocket"

"v.io/v23/context"
"v.io/v23/flow"
"v.io/x/ref/runtime/protocols/lib/tcputil"
)

// TODO(jhahn): Figure out a way for this mapping to be shared.
Expand Down Expand Up @@ -46,11 +44,18 @@ func (WS) Dial(ctx *context.T, protocol, address string, timeout time.Duration)
return nil, err
}

//nolint:staticcheck //lint:ignore SA1019
ws, _, err := websocket.NewClient(conn, u, http.Header{}, bufferSize, bufferSize)
dialer := &websocket.Dialer{
ReadBufferSize: bufferSize,
WriteBufferSize: bufferSize,
NetDial: func(net, addr string) (net.Conn, error) {
return conn, nil
},
}
ws, resp, err := dialer.DialContext(ctx, u.String(), http.Header{})
if err != nil {
return nil, err
}
resp.Body.Close()
var zero time.Time
conn.SetDeadline(zero) //nolint:errcheck
return WebsocketConn(ws), nil
Expand Down
1 change: 1 addition & 0 deletions x/ref/services/internal/pproflib/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func TestPProfProxy(t *testing.T) {
if err == nil && resp.StatusCode == 200 {
break
}
resp.Body.Close()
time.Sleep(time.Second)
}

Expand Down

0 comments on commit e03230a

Please sign in to comment.