-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
false positive on first class function #19
Comments
It looks like passing the func pick(one *error, two io.Closer) {
if err := two.Close(); one != nil && *one == nil {
*one = err
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
summary
Similar to #18, when the
http.Response.Body.Close
method is extracted and called,bodyclose
misses the call and incorrectly warns:background
While this example is so simple as to be meaningless, the core problem comes up when trying to handle the potential error that
io.Closer.Close
can return:This is resolved if you inline/duplicate the pick method,
defer func() {if close := resp.Body.Close(); err == nil { err = close } }()
, since now there is a direct call toresp.Body.Close()
, but the polymorphism and convenience of making a function for this is paramount.It is also worth noting that
defer func(f func() error) { f() }(resp.Body.Close)
also fails.The text was updated successfully, but these errors were encountered: