Skip to content

Fix local task check under a go1.26 module (staticcheck + golangci-lint)#20

Merged
jbeda merged 2 commits into
mainfrom
fix-staticcheck-toolchain
Jul 22, 2026
Merged

Fix local task check under a go1.26 module (staticcheck + golangci-lint)#20
jbeda merged 2 commits into
mainfrom
fix-staticcheck-toolchain

Conversation

@jbeda

@jbeda jbeda commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Problem

task check failed locally at two steps, both the same root cause: a Go tool built by an older toolchain can't analyze this module's go 1.26 code.

  • staticcheck v0.7.0 (a Go-1.25-era release): run as go run …@v0.7.0, its own go.mod makes the toolchain resolve to 1.25.x → package requires newer Go version go1.26.
  • golangci-lint: the locally-installed binary was built with go1.25 → the Go language version (go1.25) used to build golangci-lint is lower than the targeted Go version (1.26). (Masked until staticcheck was fixed.)

CI was always greensetup-go pins GOTOOLCHAIN=local with go1.26 installed, and CI's golangci-lint comes from the pinned action, not a stale local binary. This was purely a local task check problem.

Fix

Set GOTOOLCHAIN=go1.26.0+auto (a go1.26 floor that still auto-upgrades) on both tasks, and run golangci-lint via go run …/golangci-lint@v2.12.2 (matching CI's action version) instead of a PATH binary. Both tools are then built by go1.26+ regardless of the ambient toolchain.

go1.26.0+auto rather than local because the task runner's ambient go here is 1.24.4; local would pin to that and fail.

Verified

task check now passes end to end locally (vet, staticcheck, lint = 0 issues, test, lint-models, render-check, validate-plugin) — previously it died at staticcheck, then at lint.

Drop the staticcheck override once v0.8.0 ships stable (it builds on go1.26 natively; only v0.8.0-rc.1 exists today).

🤖 Generated with Claude Code

jbeda added 2 commits July 21, 2026 17:53
staticcheck v0.7.0 is a Go 1.25-era release. Invoked as
`go run …/staticcheck@v0.7.0`, the toolchain resolves to 1.25.x from
staticcheck's own module, and a 1.25-built staticcheck can't analyze this
module's go1.26 code ("package requires newer Go version go1.26"). Set
GOTOOLCHAIN=go1.26.0+auto on the task so staticcheck is built by go1.26 or
newer regardless of the ambient toolchain.

CI was unaffected (setup-go pins GOTOOLCHAIN=local with go1.26 installed);
this only fixed the local `task check` path. Drop the override once
staticcheck v0.8.0 ships stable — it requires and builds on go1.26.

Signed-off-by: Joe Beda <joe@stacklok.com>
Same root cause as the staticcheck fix: a golangci-lint binary built with an
older Go toolchain refuses to target this module's go1.26 code ("the Go
language version (go1.25) used to build golangci-lint is lower than the
targeted Go version (1.26)"). Run the pinned version via `go run` with the
same GOTOOLCHAIN=go1.26.0+auto floor, so it's built by go1.26+ regardless of
any locally installed golangci-lint, and pin it to CI's action version
(v2.12.2). `task check` now passes end to end locally.

Signed-off-by: Joe Beda <joe@stacklok.com>
@jbeda jbeda changed the title Fix local task staticcheck under a go1.26 module Fix local task check under a go1.26 module (staticcheck + golangci-lint) Jul 22, 2026
@jbeda
jbeda merged commit 994a49b into main Jul 22, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant