Command-Line
$ golangci-lint -h
Usage:
golangci-lint [flags]
golangci-lint [command]
Available Commands:
cache Cache control and information
completion Generate the autocompletion script for the specified shell
config Config file information
custom Build a version of golangci-lint with custom linters
fmt Format Go source files
formatters List current formatters configuration
help Help
linters List current linters configuration
migrate Migrate configuration file from v1 to v2
run Run the linters
version Version
Flags:
--color string Use color when printing; can be 'always', 'auto', or 'never' (default "auto")
-h, --help Help for a command
-v, --verbose Verbose output
--version Print version
Use "golangci-lint [command] --help" for more information about a command.
run
$ golangci-lint run -h
Usage:
golangci-lint run [flags]
Flags:
-c, --config PATH Read config from file path PATH
--no-config Don't read config file
--default string Default set of linters to enable (default "standard")
-D, --disable strings Disable specific linter
-E, --enable strings Enable specific linter
--enable-only strings Override linters configuration section to only run the specific linter(s)
--fast-only Filter enabled linters to run only fast linters
-j, --concurrency int Number of CPUs to use (Default: Automatically set to match Linux container CPU quota and fall back to the number of logical CPUs in the machine)
--modules-download-mode string Modules download mode. If not empty, passed as -mod=<mode> to go tools
--issues-exit-code int Exit code when issues were found (default 1)
--build-tags strings Build tags
--timeout duration Timeout for total work. Disabled by default
--tests Analyze tests (*_test.go) (default true)
--allow-parallel-runners Allow multiple parallel golangci-lint instances running.
If false (default) - golangci-lint acquires file lock on start.
--allow-serial-runners Allow multiple golangci-lint instances running, but serialize them around a lock.
If false (default) - golangci-lint exits with an error if it fails to acquire file lock on start.
--path-prefix string Path prefix to add to output
--path-mode string Path mode to use (empty, or 'abs')
--show-stats Show statistics per linter (default true)
--output.text.path stdout Output path can be either stdout, `stderr` or path to the file to write to.
--output.text.print-linter-name Print linter name in the end of issue text. (default true)
--output.text.print-issued-lines Print lines of code with issue. (default true)
--output.text.colors Use colors. (default true)
--output.json.path stdout Output path can be either stdout, `stderr` or path to the file to write to.
--output.tab.path stdout Output path can be either stdout, `stderr` or path to the file to write to.
--output.tab.print-linter-name Print linter name in the end of issue text. (default true)
--output.tab.colors Use colors. (default true)
--output.html.path stdout Output path can be either stdout, `stderr` or path to the file to write to.
--output.checkstyle.path stdout Output path can be either stdout, `stderr` or path to the file to write to.
--output.code-climate.path stdout Output path can be either stdout, `stderr` or path to the file to write to.
--output.junit-xml.path stdout Output path can be either stdout, `stderr` or path to the file to write to.
--output.junit-xml.extended Support extra JUnit XML fields.
--output.teamcity.path stdout Output path can be either stdout, `stderr` or path to the file to write to.
--output.sarif.path stdout Output path can be either stdout, `stderr` or path to the file to write to.
--max-issues-per-linter int Maximum issues count per one linter. Set to 0 to disable (default 50)
--max-same-issues int Maximum count of issues with the same text. Set to 0 to disable (default 3)
--uniq-by-line Make issues output unique by line (default true)
-n, --new Show only new issues: if there are unstaged changes or untracked files, only those changes are analyzed, else only changes in HEAD~ are analyzed.
It's a super-useful option for integration of golangci-lint into existing large codebase.
It's not practical to fix all existing issues at the moment of integration: much better to not allow issues in new code.
For CI setups, prefer --new-from-rev=HEAD~, as --new can skip linting the current patch if any scripts generate unstaged files before golangci-lint runs.
--new-from-rev REV Show only new issues created after git revision REV
--new-from-patch PATH Show only new issues created in git patch with file path PATH
--new-from-merge-base string Show only new issues created after the best common ancestor (merge-base against HEAD)
--whole-files Show issues in any part of update files (requires new-from-rev or new-from-patch)
--fix Fix found issues (if it's supported by the linter)
--cpu-profile-path string Path to CPU profile output file
--mem-profile-path string Path to memory profile output file
--trace-path string Path to trace output file
Global Flags:
--color string Use color when printing; can be 'always', 'auto', or 'never' (default "auto")
-h, --help Help for a command
-v, --verbose Verbose output
When the --cpu-profile-path
or --mem-profile-path
arguments are specified,
golangci-lint writes runtime profiling data in the format expected by the pprof visualization tool.
When the --trace-path
argument is specified, golangci-lint
writes runtime tracing data in the format expected by
the go tool trace
command and visualization tool.
fmt
$ golangci-lint fmt -h
Usage:
golangci-lint fmt [flags]
Flags:
-c, --config PATH Read config from file path PATH
--no-config Don't read config file
-E, --enable strings Enable specific formatter
-d, --diff Display diffs instead of rewriting files
--diff-colored Display diffs instead of rewriting files (with colors)
--stdin Use standard input for piping source files
Global Flags:
--color string Use color when printing; can be 'always', 'auto', or 'never' (default "auto")
-h, --help Help for a command
-v, --verbose Verbose output
migrate
$ golangci-lint migrate -h
Usage:
golangci-lint migrate [flags]
Flags:
-c, --config PATH Read config from file path PATH
--no-config Don't read config file
--format string Output file format.
By default, the format of the input configuration file is used.
It can be 'yml', 'yaml', 'toml', or 'json'.
--skip-validation Skip validation of the configuration file against the JSON Schema for v1.
Global Flags:
--color string Use color when printing; can be 'always', 'auto', or 'never' (default "auto")
-h, --help Help for a command
-v, --verbose Verbose output
formatters
$ golangci-lint formatters -h
Usage:
golangci-lint formatters [flags]
Flags:
-c, --config PATH Read config from file path PATH
--no-config Don't read config file
-E, --enable strings Enable specific formatter
--json Display as JSON
Global Flags:
--color string Use color when printing; can be 'always', 'auto', or 'never' (default "auto")
-h, --help Help for a command
-v, --verbose Verbose output
help
$ golangci-lint help -h
Usage:
golangci-lint help [flags]
golangci-lint help [command]
Available Commands:
formatters Help about formatters
linters Help about linters
Global Flags:
--color string Use color when printing; can be 'always', 'auto', or 'never' (default "auto")
-h, --help Help for a command
-v, --verbose Verbose output
Use "golangci-lint help [command] --help" for more information about a command.
linters
$ golangci-lint linters -h
Usage:
golangci-lint linters [flags]
Flags:
-c, --config PATH Read config from file path PATH
--no-config Don't read config file
--default string Default set of linters to enable (default "standard")
-D, --disable strings Disable specific linter
-E, --enable strings Enable specific linter
--enable-only strings Override linters configuration section to only run the specific linter(s)
--fast-only Filter enabled linters to run only fast linters
--json Display as JSON
Global Flags:
--color string Use color when printing; can be 'always', 'auto', or 'never' (default "auto")
-h, --help Help for a command
-v, --verbose Verbose output
cache
Golangci-lint stores its cache in the subdirectory golangci-lint
inside the default user cache directory.
You can override the default cache directory with the environment variable GOLANGCI_LINT_CACHE
; the path must be absolute.
The cache is only used by golangci-lint run
(linters).
$ golangci-lint cache -h
Usage:
golangci-lint cache [flags]
golangci-lint cache [command]
Available Commands:
clean Clean cache
status Show cache status
Global Flags:
--color string Use color when printing; can be 'always', 'auto', or 'never' (default "auto")
-h, --help Help for a command
-v, --verbose Verbose output
Use "golangci-lint cache [command] --help" for more information about a command.
config
$ golangci-lint config -h
Usage:
golangci-lint config [flags]
golangci-lint config [command]
Available Commands:
path Print used config path
verify Verify configuration against JSON schema
Flags:
-c, --config PATH Read config from file path PATH
--no-config Don't read config file
Global Flags:
--color string Use color when printing; can be 'always', 'auto', or 'never' (default "auto")
-h, --help Help for a command
-v, --verbose Verbose output
Use "golangci-lint config [command] --help" for more information about a command.
custom
$ golangci-lint custom -h
Usage:
golangci-lint custom [flags]
Global Flags:
--color string Use color when printing; can be 'always', 'auto', or 'never' (default "auto")
-h, --help Help for a command
-v, --verbose Verbose output
version
$ golangci-lint version -h
Usage:
golangci-lint version [flags]
Flags:
--debug Add build information
--json Display as JSON
--short Display only the version number
Global Flags:
--color string Use color when printing; can be 'always', 'auto', or 'never' (default "auto")
-h, --help Help for a command
-v, --verbose Verbose output
completion
$ golangci-lint completion -h
Usage:
golangci-lint completion [command]
Available Commands:
bash Generate the autocompletion script for bash
fish Generate the autocompletion script for fish
powershell Generate the autocompletion script for powershell
zsh Generate the autocompletion script for zsh
Global Flags:
--color string Use color when printing; can be 'always', 'auto', or 'never' (default "auto")
-h, --help Help for a command
-v, --verbose Verbose output
Use "golangci-lint completion [command] --help" for more information about a command.
Last updated on