Checks that method receivers of a type are named consistently.
func (i *Item) Execute() {} // OK
func (t *Item) Cancel() {} // not OK
Checks that all exported identifiers are documented (including field names, variable, constant, function, struct and interface declarations). Optionally checks that each comment starts with the name of the item it describes.
Available options:
has_ident_prefix: bool
- ensure that every doc comment begins with the name of the item it describes.
// Runner is documented.
type Runner interface {
// Run is documented.
Run()
// This method is not documented properly.
Stop() error
}
Checks that when a numerical quantifier appears in a binary expression it is the left operand.
_ = 5 * time.Minute // OK
_ = time.Minute * 5 // not OK
Checks that the code lines are within specific length limits.
Available options:
max_length: int
- the maximum number of characters permitted on a single line.tab_width: int
- the number of characters equivalent to a single tab.
Checks that exported functions return exported (and internal) types only.
func (i *Item) Do() result {} // not OK, `result` should be exported
Checks the correctness of type names. Correct type names adhere to the following rules:
- PascalCase for exported types.
- camelCase for non-exported types.
type processTracker struct{} // OK
type ProcessTracker struct{} // OK
type process_tracker struct{} // not OK
Checks function declarations which have context.Context
in them. If the context is not
the first argument, the checker will report an error.
func Get(id string, ctx context.Context) () {} // not OK, `ctx` should be first
Checks that error
is the last value returned by a function.
func Create() (int, error, bool) {} // not OK, `error` should be last
Checks that tests are placed in *_test
packages only.
package feature // not OK, should be `feature_test`
import "testing"
func TestFeature(t *testing.T) {}