// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// The errorsas package defines an Analyzer that checks that the second arugment to
+// The errorsas package defines an Analyzer that checks that the second argument to
// errors.As is a pointer to a type implementing error.
package errorsas
"golang.org/x/tools/go/types/typeutil"
)
-const doc = `report passing non-pointer or non-error values to errors.As
+const Doc = `report passing non-pointer or non-error values to errors.As
The errorsas analysis reports calls to errors.As where the type
of the second argument is not a pointer to a type implementing error.`
var Analyzer = &analysis.Analyzer{
Name: "errorsas",
- Doc: doc,
+ Doc: Doc,
Requires: []*analysis.Analyzer{inspect.Analyzer},
Run: run,
}
return // not enough arguments, e.g. called with return values of another function
}
if fn.FullName() == "errors.As" && !pointerToInterfaceOrError(pass, call.Args[1]) {
- pass.Reportf(call.Pos(), "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 pointer to an interface or a type implementing error")
}
})
return nil, nil