How to ignore error returned by local function
mxinden opened this issue · 3 comments
mxinden commented
How can I ignore the error returned by the local function myLocalFunc
?
main.go
:
package main
func main() {
myLocalFunc := func() error {
return nil
}
myLocalFunc()
}
(https://play.golang.org/p/WClnCYmq4ne)
ignore.txt
:
myLocalFunc
(github.com/mxinden/errcheck_test).myLocalFunc
(*github.com/mxinden/errcheck_test).myLocalFunc
github.com/mxinden/errcheck_test.myLocalFunc
*github.com/mxinden/errcheck_test.myLocalFunc
errcheck
output:
# Inside $GOPATH/github.com/mxinden/errcheck_test
$ errcheck -verbose -exclude ignore.txt ./...
Excluding myLocalFunc
Excluding (github.com/mxinden/errcheck_test).myLocalFunc
Excluding (*github.com/mxinden/errcheck_test).myLocalFunc
Excluding github.com/mxinden/errcheck_test.myLocalFunc
Excluding *github.com/mxinden/errcheck_test.myLocalFunc
Checking github.com/mxinden/errcheck_test
main.go:8:13: myLocalFunc()
errcheck version 1787c4b
dtcaciuc commented
Consider using _ = myLocalFunc()
. This makes errcheck happy and it's also unambiguous that you're intentionally ignoring the error when someone reads the code.