Skip to content
Latchkey

golangci-lint "typecheck" errors - Fix in CI

golangci-lint runs the type checker before its analyzers. If the code does not compile, you get "typecheck" errors and the real lint findings are hidden behind a build failure.

What this error means

golangci-lint reports typecheck errors such as undeclared names or missing imports. The package does not compile, so the linter cannot type-check it.

go
main.go:8:2: undeclared name: fmtt (typecheck)

Common causes

Code does not compile

A genuine build error (typo, missing import) stops type-checking, surfacing as a typecheck finding.

Wrong Go version for the linter

golangci-lint was built against a different Go than the code targets, so newer syntax fails to type-check.

How to fix it

Fix the build first

  1. Run go build ./... and resolve the compile errors before re-running the linter.
shell
go build ./...
golangci-lint run

Match the linter to your Go

  1. Install a golangci-lint built against the Go version your code uses.
.github/workflows/ci.yml
- uses: golangci/golangci-lint-action@v6
  with:
    version: latest

How to prevent it

  • Ensure go build passes before running golangci-lint.
  • Keep golangci-lint and the Go toolchain version-aligned.
  • Run the linter locally before pushing.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →