Provides a River hook for detecting a common accidental Go problem where a nil struct value is wrapped in a non-nil interface value. This commonly causes trouble with the error interface, where an unintentional non-nil error is returned. For example:
func returnsError() error {
var p *MyError = nil
if bad() {
p = ErrBad
}
return p // Will always return a non-nil error.
}See https://go.dev/doc/faq#nil_error.
See example_hook_test.go for usage details.
The hook supports these options:
hook := nilerror.NewHook(&HookConfig{
Suppress: true,
})Suppress: Causes the hook to suppress detected nil struct values wrapped in non-nil error interface values and produce warning logging instead.