diff --git a/go/analysis/passes/errorsas/errorsas.go b/go/analysis/passes/errorsas/errorsas.go index b80271afb9..384f025570 100644 --- a/go/analysis/passes/errorsas/errorsas.go +++ b/go/analysis/passes/errorsas/errorsas.go @@ -51,7 +51,7 @@ func run(pass *analysis.Pass) (interface{}, error) { return // not enough arguments, e.g. called with return values of another function } if fn.FullName() == "errors.As" && !pointerToInterfaceOrError(pass, call.Args[1]) { - pass.ReportRangef(call, "second argument to errors.As must be a pointer to an interface or a type implementing error") + pass.ReportRangef(call, "second argument to errors.As must be a non-nil pointer to either a type that implements error, or to any interface type") } }) return nil, nil diff --git a/go/analysis/passes/errorsas/testdata/src/a/a.go b/go/analysis/passes/errorsas/testdata/src/a/a.go index d13dee264f..c987a8a650 100644 --- a/go/analysis/passes/errorsas/testdata/src/a/a.go +++ b/go/analysis/passes/errorsas/testdata/src/a/a.go @@ -34,10 +34,10 @@ func _() { errors.As(nil, perr()) // *error, via a call errors.As(nil, ei) // empty interface - errors.As(nil, nil) // want `second argument to errors.As must be a pointer to an interface or a type implementing error` - errors.As(nil, e) // want `second argument to errors.As must be a pointer to an interface or a type implementing error` - errors.As(nil, m) // want `second argument to errors.As must be a pointer to an interface or a type implementing error` - errors.As(nil, f) // want `second argument to errors.As must be a pointer to an interface or a type implementing error` - errors.As(nil, &i) // want `second argument to errors.As must be a pointer to an interface or a type implementing error` + errors.As(nil, nil) // want `second argument to errors.As must be a non-nil pointer to either a type that implements error, or to any interface type` + errors.As(nil, e) // want `second argument to errors.As must be a non-nil pointer to either a type that implements error, or to any interface type` + errors.As(nil, m) // want `second argument to errors.As must be a non-nil pointer to either a type that implements error, or to any interface type` + errors.As(nil, f) // want `second argument to errors.As must be a non-nil pointer to either a type that implements error, or to any interface type` + errors.As(nil, &i) // want `second argument to errors.As must be a non-nil pointer to either a type that implements error, or to any interface type` errors.As(two()) }