A package-level error variable is not named with the prefix Err or err

tx0/go:error-variable-namestrictwarningstyle/namingdepth faststyle

What it finds

var NotFound = errors.New("not found"): errors that a package declares for callers to compare with are named ErrNotFound, or errNotFound when unexported, so that their role is clear wherever they are used, as with io.EOF's neighbours io.ErrClosedPipe and os.ErrNotExist.

Reported are variables declared at the top level with the value of errors.New or fmt.Errorf whose name does not start with Err or err.

From the rule's source, error_variable_name.rs.

Example from the rule's tests
package p import "errors" var NotFound = errors.New("not found")tx0 reports: the error NotFound is not named Err... or err... var ErrClosed = errors.New("closed") var errBusy = errors.New("busy")
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/go:error-variable-name" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/go:error-variable-name] reason="..."

tx0 explain tx0/go:error-variable-name shows the same in the terminal. Found a false positive? Report it.