Skip to content

build: lower go.mod directive to actual minimum required - #62

Merged
sbldevnet merged 1 commit into
mainfrom
fix/lower-go-mod-directive
Sep 28, 2026
Merged

sbldevnet merged 1 commit into
mainfrom
fix/lower-go-mod-directive

Conversation

@sbldevnet

Copy link
Copy Markdown
Owner

Summary

  • Lowers go.mod's go directive from 1.27.1 (latest stable, pinned with no code justification) to 1.26.0.
  • No toolchain line is added: CI/release already use go-version-file: go.mod (setup-go), so they'll simply build with 1.26.0 going forward — nothing in this repo needs a newer toolchain than the floor.

How the minimum was determined

  1. Checked the language/stdlib floors the code actually uses, via go build -gcflags="-lang=go1.2X" ./... at decreasing X:
    • Generics (atomic.Pointer[T], token.go/proxy.go) → needs go1.18.
    • errors.Join → go1.20.
    • math/rand/v2 → go1.22.
    • proxy.serve's go func() { ... proxyConfig ... }() inside a for _, proxyConfig := range configs loop relies on Go's per-iteration loop-variable semantics (Go 1.22+) — with an older go directive this closure would silently capture the shared loop variable across goroutines, a real data-race/logic bug, not just a syntax check. This pushes the language floor to 1.22.
  2. However, -lang only checks syntax, not the module graph. Running go mod tidy after setting go 1.22 auto-raised the directive to 1.26.0, because golang.org/x/sync v0.23.0 (already pinned, used for singleflight) declares go 1.26.0 in its own go.mod — that's a stricter, binding floor imposed by an existing dependency pin, independent of anything in this repo's own code.
  3. Verified the floor is exact: go build ./... with go 1.25.0 fails (updates to go.mod needed; to update it: go mod tidy); with go 1.26.0 it builds cleanly.

So the actual, tooling-verified minimum is go 1.26.0 — one minor version below the previous 1.27.1 pin, not 1.22 as the raw language-feature scan alone would suggest, because of the x/sync dependency's own floor. Did not touch dependency versions (out of scope for this issue); happy to explore downgrading x/sync in a follow-up if a lower floor is wanted.

Test plan

  • go mod tidy — no further changes beyond the go directive
  • go build ./...
  • go vet ./...
  • go test -race ./... — all packages pass
  • Confirmed go 1.25.0 fails to build (proves 1.26.0 is the true floor, not an arbitrary choice)

…quires

The go directive was pinned to 1.27.1 (latest stable) with no code-level
justification. Determined via go build -gcflags="-lang=go1.2X" ./... that
the code's own syntax/stdlib usage (generics, atomic.Pointer[T],
errors.Join, math/rand/v2, and the per-iteration for-range loop variable
semantics relied on in proxy.serve's goroutine closure) only needs 1.22.

The actual binding floor is higher: golang.org/x/sync v0.23.0 (already
pinned, providing singleflight) declares go 1.26.0 in its own go.mod, and
go mod tidy raises the directive accordingly. go 1.25.0 fails go build
with "updates to go.mod needed"; go 1.26.0 builds, vets, and passes
go test -race cleanly.
@sbldevnet
sbldevnet merged commit 06fe2d0 into main Sep 28, 2026
4 checks passed
@sbldevnet
sbldevnet deleted the fix/lower-go-mod-directive branch September 28, 2026 11:15
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