-
Notifications
You must be signed in to change notification settings - Fork 26
feat: Repo-controlled Go version via .go-version #440
Copy link
Copy link
Open
Labels
Description
Problem
The Go version is specified independently in 5 places with no local enforcement:
- .settings.yaml (languages.go: '1.26.1') — CI workflows
- go.mod (go 1.26.1) — module minimum
- Makefile (go env GOVERSION) — local build uses whatever is installed
- validators/deployment/Dockerfile — hardcoded golang:1.26.1-bookworm
- validators/performance/Dockerfile — hardcoded golang:1.26.1-bookworm
- validators/conformance/Dockerfile — hardcoded golang:1.26.1-bookworm
A developer with the wrong Go version installed will silently build with it. Bumping Go requires editing 5+ files.
There is no local enforcement.
Proposal
Add a .go-version file as the single source of truth, following the same pattern used by
coredns/coredns@5556180. .go-version is a plain text
file (no yq dependency) and is natively supported by actions/setup-go via go-version-file.
Changes
- Add .go-version containing 1.26.1
- Makefile — read from .go-version and export GOTOOLCHAIN to enforce locally:
GO_VERSION ?= $(shell cat .go-version)
export GOTOOLCHAIN = go$(GO_VERSION) - CI workflows — replace go-version: ${{ steps.versions.outputs.go }} with go-version-file: .go-version
(eliminates the load-versions dependency for Go) - Dockerfiles — use build arg fed from .go-version:
ARG GO_VERSION=1.26.1
FROM golang:${GO_VERSION}-bookworm AS builder - .settings.yaml — remove languages.go (no longer the source of truth for Go)
- load-versions action — read Go version from .go-version instead of .settings.yaml
Bump Go version = edit one file (.go-version), everything follows.
References
- CoreDNS implementation: coredns/coredns@5556180
- actions/setup-go go-version-file support:
https://github.com/actions/setup-go#getting-go-version-from-the-go-version-file
Reactions are currently unavailable