Quick Start
Linting
To run golangci-lint:
golangci-lint runIt’s an equivalent of:
golangci-lint run ./...You can choose which directories or files to analyze:
golangci-lint run dir1 dir2/...
golangci-lint run file1.goDirectories are NOT analyzed recursively.
To analyze them recursively append /... to their path.
It’s not possible to mix files and packages/directories, and files must come from the same package.
Golangci-lint can be used with zero configuration. By default, the following linters are enabled:
$ golangci-lint help linters
Enabled by default linters:
errcheck: Errcheck is a program for checking for unchecked errors in Go code. These unchecked errors can be critical bugs in some cases.
govet: Vet examines Go source code and reports suspicious constructs. It is roughly the same as 'go vet' and uses its passes. [auto-fix]
ineffassign: Detects when assignments to existing variables are not used. [fast]
staticcheck: It's the set of rules from staticcheck. [auto-fix]
unused: Checks Go code for unused constants, variables, functions and types.
Pass -E/--enable to enable linter and -D/--disable to disable:
golangci-lint run --default=none -E errcheckMore information about available linters can be found in the linters page.
Formatting
To format your code:
golangci-lint fmtYou can choose which directories or files to analyze:
golangci-lint fmt dir1 dir2/...
golangci-lint fmt file1.goMore information about available formatters can be found in the formatters page.
Last updated on