Skip to content
Latchkey

golangci-lint run: Lint a Go Module in CI

golangci-lint run lints the packages you point it at and exits non-zero when any enabled linter reports an issue.

golangci-lint bundles dozens of Go linters behind one binary and one config. In CI you run it across the module and gate on its exit code.

What it does

golangci-lint run loads the Go packages under the given paths (default the current directory), runs every enabled linter once over a shared type-checked AST, and prints the combined issues. It exits 1 when issues are found, 0 when clean, and a higher code on its own errors.

Common usage

Terminal
golangci-lint run ./...
# only report issues introduced since main
golangci-lint run --new-from-rev origin/main ./...
# raise the per-run timeout for a large module
golangci-lint run --timeout 5m ./...

Flags

FlagWhat it does
./...Path pattern; lint all packages recursively
--timeout <dur>Deadline for the whole run (default 1m)
--new-from-rev <rev>Only show issues new since a git revision
--newOnly show issues in uncommitted changes
--concurrency <n>Number of parallel workers
-v / --verbosePrint which linters ran and timing

In CI

Pin the binary version (the official action takes a version: input) so a new release does not change which linters fire under your config. golangci-lint exit code 1 means lint issues; code 3 means a config or run error such as an unknown linter, so treat them differently in scripts.

Common errors in CI

"level=error msg=\"Running error: context deadline exceeded\"" means the run hit --timeout; raise it. "can't load config: unsupported version of the configuration" means the .golangci.yml version: does not match the binary (v2 config needs golangci-lint v2). "directory prefix . does not contain main module" means the working directory is not the module root.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →