golangci-lint "context deadline exceeded" - Fix in CI
golangci-lint aborts the whole run when its deadline passes. On a large module or a cold cache, the default timeout is often too short, so the run dies before finishing.
What this error means
golangci-lint exits with context deadline exceeded and no findings. The analysis took longer than the configured (or default 1m) timeout, usually on a cold cache.
level=error msg="Running error: context loading failed: ... context deadline exceeded"Common causes
Timeout too low for the module
A big codebase with many analyzers exceeds the default one-minute budget.
Cold build/lint cache
Without a warm cache every package is analyzed from scratch, blowing the deadline.
How to fix it
Raise the timeout
- Give the run a larger deadline that fits the codebase.
run:
timeout: 5mCache the analysis between runs
- Cache the Go build and golangci-lint caches so repeat runs are fast.
- uses: actions/cache@v4
with:
path: ~/.cache/golangci-lint
key: golangci-${{ hashFiles('**/go.sum') }}How to prevent it
- Set a realistic timeout in .golangci.yml.
- Cache the lint and build caches across CI runs.
- Disable redundant linters to cut analysis time.