Skip to content

Commit

Permalink
add explicit close response body function.
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangkun committed Nov 28, 2023
1 parent 6e729de commit d3cd5ff
Show file tree
Hide file tree
Showing 5 changed files with 1,437 additions and 66 deletions.
2 changes: 0 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,11 @@ linters-settings:
linters:
disable-all: true
enable:
- deadcode
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- structcheck
- stylecheck
- typecheck
- unused
Expand Down
3 changes: 3 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,13 @@ func (c *Client) Do(ctx context.Context, req IRequest) (IResponse, error) {
request.Header.Set(headerUserAgent, defaultUA)
}
var response *http.Response
// nolint: bodyclose
response, err = c.client.Do(request)
if err != nil {
return nil, err
}
// response body is closed by caller
// actually, it's automatically closed by Data access
var rsp = NewResponse(response)
// run after hooks
c.runAfterHooks(req, rsp)
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ go 1.16

require (
github.com/fatih/structtag v1.2.0
github.com/pinealctx/neptune v0.8.4-0.20220513082456-ea94fa5e23b9
go.uber.org/zap v1.19.0
github.com/pinealctx/neptune v1.2.4
go.uber.org/zap v1.26.0
)
Loading

0 comments on commit d3cd5ff

Please sign in to comment.