Skip to content

fix(golang): respect a caller-set GOTOOLCHAIN when installing hook envs#32

Merged
blairham merged 1 commit into
mainfrom
fix/respect-env-gotoolchain
Jul 5, 2026
Merged

fix(golang): respect a caller-set GOTOOLCHAIN when installing hook envs#32
blairham merged 1 commit into
mainfrom
fix/respect-env-gotoolchain

Conversation

@blairham

@blairham blairham commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Problem

InstallEnvironment for language: golang hooks unconditionally appends GOTOOLCHAIN=local, overriding any toolchain the caller pinned in the environment.

In pinpredict CI, pre-commit-advisory.yml pins GOTOOLCHAIN=go<max go.mod version> exactly so hook builds can auto-provision a Go newer than the runner's PATH go. The hardcoded local defeats that pin, and every golang hook env install fails on runners whose Go lags the hook module's requirement:

failed to install environment for hook "golangci-lint-fmt": go install failed:
go: go.mod requires go >= 1.25.0 (running go 1.24.13; GOTOOLCHAIN=local)

(golangci-lint v2.12.2 requires go ≥ 1.25.0; ubuntu-latest currently ships 1.24.13.) This has failed the advisory job in every pinpredict Go repo on cache miss since the standardized hooks landed — including on their main branches.

Fix

Append GOTOOLCHAIN=local only when the caller hasn't set GOTOOLCHAIN. The hermetic default is unchanged; an explicit pin now passes through. Env construction extracted to goInstallEnv with unit tests for both cases.

Gate: make check (76/76 parity) + make lint (0 issues) green.

🤖 Generated with Claude Code

InstallEnvironment unconditionally appended GOTOOLCHAIN=local, clobbering
any toolchain the caller pinned. In CI (pinpredict pre-commit-advisory)
the workflow pins GOTOOLCHAIN=go<repo version> precisely so hooks whose
module requires a newer Go than the runner's PATH go can build — e.g.
golangci-lint v2.12.2 needs go >= 1.25.0 while ubuntu-latest ships
1.24.13, so every golang hook install failed with 'go.mod requires
go >= 1.25.0 (running go 1.24.13; GOTOOLCHAIN=local)'.

Default to local only when GOTOOLCHAIN is unset; an explicit caller
value now passes through.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@blairham
blairham merged commit a4f8a1a into main Jul 5, 2026
5 checks passed
@blairham
blairham deleted the fix/respect-env-gotoolchain branch July 5, 2026 14:52
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