retnonnilerr
retnonnilerr
is a static analysis tool to prevent below unhandling error.
func f() error {
x, err := fn()
if err != nil {
return nil // !!!
}
fmt.Printf("x is %v\n", x)
return nil
}
How to use
From CLI
go install github.com/MokkeMeguru/retnonnilerr/cmd/retnonnilerr
cd path/to/product
retnonnilerr ./...
From CI
See my custom linter settings
Test it using act (WARNING: reviewdog cannot do normaly)
act --job reviewdog
Ignore Lint?
If you want to ignore this linter at the line, you can comment lint:ignore retnonnilerr
.
func f() error {
x, err := fn()
if err != nil {
//lint:ignore retnonnilerr TODO fix
return nil
}
fmt.Printf("x is %v\n", x)
return nil
}
References