Skip to content

Split the go directive from the toolchain in go.mod - #14

Closed
np5 wants to merge 1 commit into
mainfrom
20261019_go_toolchain_split
Closed

np5 wants to merge 1 commit into
mainfrom
20261019_go_toolchain_split

Conversation

@np5

@np5 np5 commented Oct 19, 2026

Copy link
Copy Markdown
Member

Standardises on the go + toolchain split that terraform-provider-zentral already used.

What changes

-go 1.26.9
+go 1.26.0
+toolchain go1.26.9

The two directives mean different things and go 1.26.9 conflated them:

  • go is the minimum language version the module requires — a floor, and for consumers of the module, a constraint.
  • toolchain is what actually builds it.

Declaring 1.26.9 as the language floor claims the code needs 1.26.9 language features, which it does not.

Nothing about the build changes

setup-go resolves the toolchain directive, so go-version-file: go.mod keeps installing 1.26.9 — verified on terraform-provider-zentral, whose govulncheck run reports Successfully set up Go version 1.26.9 from exactly this shape of go.mod.

Demonstrated the other half too: in a golang:1.25.3 container with GOTOOLCHAIN=auto, the directive makes Go fetch and switch to 1.26.9 on its own (go version go1.26.9). An older local toolchain now upgrades itself rather than silently building with the wrong one.

Verification

Built and vetted in golang:1.26.9; go mod verify clean.

🤖 Generated with Claude Code

go.mod said `go 1.26.9`, which conflates two different things. The `go`
directive is the minimum language version the module requires; `toolchain`
is which toolchain to build with. Declaring 1.26.9 as the language floor
claims this code needs 1.26.9 language features, which it does not.

  go 1.26.0
  toolchain go1.26.9

This matches terraform-provider-zentral, which already declared it this way.

Nothing about the build changes: setup-go resolves the toolchain directive,
and `go-version-file: go.mod` in build.yml, release.yml and govulncheck.yml
continues to install 1.26.9. Verified in containers -- building under
golang:1.26.9 works unchanged, and under an older golang:1.25.3 with
GOTOOLCHAIN=auto the directive makes Go fetch and switch to 1.26.9 on its
own.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@np5

np5 commented Oct 19, 2026

Copy link
Copy Markdown
Member Author

Closing: the rationale did not hold up under checking.

I framed the go/toolchain split as best practice. The Go documentation supports it specifically for modules that are dependencies of other modules -- a library needing a floor lower than its preferred toolchain (go.dev/doc/toolchain). That is goztl's case, not this one: nothing imports osquery-extension, so the go line constrains no consumer.

Nor is the split common practice. Of six widely-used Go projects checked -- golang/tools, grpc-go, aws-sdk-go-v2, kubernetes, terraform, prometheus -- none carries a toolchain line, and Go's own tooling does not produce one (go get go@1.26.9 writes go 1.26.9 alone). The applications among them (terraform go 1.26.8, prometheus go 1.26.7) pin a specific patch in go, which is exactly what this repo already had.

So go 1.26.9 as it stands on main is the conventional shape for an application, and this PR would have moved it to one no peer uses. No behaviour difference either way -- setup-go installs 1.26.9 from either -- so the change was churn.

The toolchain itself is unaffected: main stays on 1.26.9 with govulncheck required.

@np5 np5 closed this Oct 19, 2026
@np5
np5 deleted the 20261019_go_toolchain_split branch October 19, 2026 14:07
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