← 返回命令列表

Linux command

golangci-lint 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Run all enabled linters

golangci-lint run

Run linters on specific packages

golangci-lint run ./cmd/... ./internal/...

Enable specific linters

golangci-lint run --enable errcheck --enable gocritic

Run only specific linters

golangci-lint run --disable-all --enable gosimple --enable govet

Show all available linters

golangci-lint linters

Run with a specific config

golangci-lint run -c [.golangci.yml]

Fix issues

golangci-lint run --fix

Output results

golangci-lint run --out-format json

说明

golangci-lint is a fast Go linter runner that aggregates dozens of linters into one tool. It provides parallel execution, result caching, and unified configuration for checking style, bugs, performance, and security issues. Configuration via .golangci.yml enables project-specific rules and linter selection, replacing the need to run individual linters separately. Results are cached between runs for speed.

参数

run
Run linters on the current project.
linters
List available linters with enabled/disabled status.
cache
Cache management commands (clean, status).
version
Display version information.
--enable _LINTER_
Enable a specific linter. Can be specified multiple times.
--disable _LINTER_
Disable a specific linter. Can be specified multiple times.
--disable-all
Disable all linters, then selectively enable with --enable.
--fix
Automatically fix issues where the linter supports it.
--out-format _FORMAT_
Output format: colored-line-number (default), json, tab, checkstyle, github-actions, etc.
--timeout _DURATION_
Timeout for the total run. Default: 1m.
--new
Only show issues from new code (based on git).
--new-from-rev _REV_
Show issues only from changes since the given git revision.
-c _FILE_, --config _FILE_
Path to config file.
--no-config
Do not read any config file.
-j _N_, --concurrency _N_
Number of concurrent linter goroutines. Default: number of CPUs.
--help
Display help information.

FAQ

What is the golangci-lint command used for?

golangci-lint is a fast Go linter runner that aggregates dozens of linters into one tool. It provides parallel execution, result caching, and unified configuration for checking style, bugs, performance, and security issues. Configuration via .golangci.yml enables project-specific rules and linter selection, replacing the need to run individual linters separately. Results are cached between runs for speed.

How do I run a basic golangci-lint example?

Run `golangci-lint run` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does run do in golangci-lint?

Run linters on the current project.