Skip to content

error-type-naming

Name error implementations with an Error suffix.

Updated View as Markdown

Default severity: warning

Named types whose value or pointer method set implements error should end in Error, making their role recognizable at API boundaries and in type assertions.

Bad

type ParseFailure struct {
	Offset int
}

func (ParseFailure) Error() string { return "parse failed" }

Good

type ParseError struct {
	Offset int
}

func (ParseError) Error() string { return "parse failed" }
Navigation

Type to search…

↑↓ navigate↵ selectEsc close