Here is the sample code to reproduce:
package main
import (
"net/http"
)
func getResponse(url string) *http.Response {
res, _ := http.Get(url)
return res
}
func main() {
resp := getResponse("https://example.com")
resp.Body.Close()
}
And the result of go vet:
go vet -vettool=$(which bodyclose) ./main.go
# command-line-arguments
./closer.go:8:20: response body must be closed
./closer.go:13:21: response body must be closed
Here is the sample code to reproduce:
And the result of go vet: