golangci-lint "level=error msg=Running error" in CI
A level=error msg="Running error: ..." from golangci-lint is not a lint finding: the analysis driver could not load or compile your packages, so most linters cannot run at all.
What this error means
golangci-lint exits non-zero printing "level=error msg=\"Running error: context loading failed: ...\"" or a typecheck/build failure, with few or no normal lint issues listed.
level=error msg="Running error: context loading failed: failed to load packages:
no Go files in /home/runner/work/app/app"
level=warning msg="Failed to run: ..."Common causes
Packages fail to compile or load
golangci-lint type-checks the code first; a build error, a missing dependency, or the wrong working directory makes package loading fail.
A Go toolchain or module mismatch
The runner's Go version or module setup differs from what the code needs, so the loader cannot resolve packages.
How to fix it
Make the code build first
- Run
go build ./...to confirm the packages compile. - Fix the build error or run golangci-lint from the module root.
- Re-run the linter once
go buildis clean.
go build ./...
golangci-lint run ./...Match the Go version golangci-lint expects
Set up the Go version your modules require before linting so package loading succeeds.
- uses: actions/setup-go@v5
with:
go-version: '1.22'How to prevent it
- Ensure
go build ./...passes before running golangci-lint. - Run the linter from the module root with the right Go version.
- Keep the linter's Go toolchain aligned with your modules.