golang/go

cmd/vet: warn about ignored error results

Closed this issue · 2 comments

With this code:

package main

func Do() error {
        return nil
}

func main() {
        Do()
}


I would like go vet to warn me that in the Do() call I'm implicitly ignoring the
returned error. This makes sense since if Do returned anything else than the error I
would be forced to explicitly ignore the error (or handle it).

I understand this could be very noisy for fmt.*, so that package may be completely
blacklisted from the check. On the other hand, this feature could avoid some common
errors while using third party libs.
rsc commented

Comment 1:

[Please use the standard summary form.]
I am skeptical about this. Every time I've seen this tried in other languages there have
been far too many false positives. Not all errors are worth checking.
rsc commented

Comment 2:

On more thought I'm almost certain this is working as intended.

Status changed to WorkingAsIntended.