False positive for httptest.ResponseRecorder
pellared opened this issue · 0 comments
pellared commented
Currently the linter expect closing the Body
of http.Response
returned by httptest.ResponseRecorder.Result()
.
Notice that closing is needed only when using http.Client
.
For sure it is not needed when using httptest.ResponseRecorder
as even closing the response body is a no-op.
See: https://github.com/golang/go/blob/86bec1ec198f2720c83bd232a72b800b4ea5a9f6/src/net/http/httptest/recorder.go#L200-L204
Tested with https://github.com/golangci/golangci-lint/releases/tag/v1.59.1 and https://github.com/open-telemetry/opentelemetry-go-contrib.
PR for reference: open-telemetry/opentelemetry-go-contrib#5962