Table of Contents
Linting
To run golangci-lint:
golangci-lint run
It'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.go
Directories 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 lintersEnabled 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 errcheck
More information about available linters can be found in the linters page.
Formatting
To format your code:
golangci-lint fmt
You can choose which directories or files to analyze:
Edit this page on GitHub
golangci-lint fmt dir1 dir2/...golangci-lint fmt file1.go