Skip to content

feat: Repo-controlled Go version via .go-version #440

@xdu31

Description

@xdu31

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

  1. Add .go-version containing 1.26.1
  2. Makefile — read from .go-version and export GOTOOLCHAIN to enforce locally:
    GO_VERSION ?= $(shell cat .go-version)
    export GOTOOLCHAIN = go$(GO_VERSION)
  3. CI workflows — replace go-version: ${{ steps.versions.outputs.go }} with go-version-file: .go-version
    (eliminates the load-versions dependency for Go)
  4. Dockerfiles — use build arg fed from .go-version:
    ARG GO_VERSION=1.26.1
    FROM golang:${GO_VERSION}-bookworm AS builder
  5. .settings.yaml — remove languages.go (no longer the source of truth for Go)
  6. load-versions action — read Go version from .go-version instead of .settings.yaml

Bump Go version = edit one file (.go-version), everything follows.

References

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions