error-naming
What it does
Section titled “What it does”A package-level var of one name made by errors.New or fmt.Errorf starts with err, or Err when exported.
Why it matters
Section titled “Why it matters”A package-level error variable is a sentinel that callers compare against with errors.Is, and it is read from other packages. The err and Err prefixes make such variables recognizable at the use site and keep the exported ones apart from other exported names. It is a Go convention; nothing breaks without it.
Example
Section titled “Example”...
import "errors"
var failed = errors.New("x")var Bad = errors.New("x")var errOK = errors.New("x")var ErrOK = fmt.Errorf("x")var _ = errors.New("x")var ( oops error = errors.New("x") one, two = errors.New("x"), errors.New("y") other = other())...Configuration
Section titled “Configuration”go: lint: rules: error-naming: warn # off (default), warn, errorEnabled by the presets: go/revive.
Suppress one line with sudsy-disable-next-line error-naming in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| revive | error-naming |
full |