Files
tailscale/docs/go-bump-checklist.md
Brad Fitzpatrick b21f560533 cmd/tsvet: replace cmd/vet, staticcheck, golangci-lint, and checklocks
We ran overlapping checks in four tools at different versions:
golangci-lint only reported problems on changed lines, vet only ran
for linux, and staticcheck took seven CI jobs, each compiling the tree
from scratch.

cmd/tsvet now runs the go vet suite, staticcheck, checklocks, and our
own analyzers as a single vettool, for linux, windows, and darwin, plus
a goimports check of all Go files. Small analyzers replace the
golangci-lint and revive checks that nothing else covered, and
lint:ignore directives work for every check.

CI runs it with the next toolchain (tailscale.go1.28), whose go vet
type checks dependencies instead of compiling them. Pushes to main
save one cache that per-GOOS PR jobs restore, and go test no longer
runs its own vet in jobs that tsvet covers.

Over the past 30 days, these checks cost about 43 runner-minutes per
PR (29 of them staticcheck's). On a 4-core machine, tsvet checks the
whole tree for all three GOOS values in 3m27s from an empty cache and
10s when nothing changed. Its cache for all three is 1.3 GB (176 MB
compressed), versus 5 GB for just linux when vet compiles with Go
1.27. Dropping golangci-lint also removes 161 lines from go.mod.

Fixes #22645
Fixes #22653

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
Change-Id: Idf8779d8d3e1f5e87a8a431a53949db9c143d236
2026-12-03 05:33:36 -08:00

4.4 KiB

Go major version bump checklist

Things to update every six months when we move to a new Go major version (e.g. Go 1.NN to Go 1.MM). See the git history of this file and past bump commits (e.g. "go.toolchain.branch: switch to Go 1.26", "go.toolchain.branch: switch to Go 1.27") for worked examples.

Prerequisites

  • The tailscale/go fork has a tailscale.goX.YY branch with our patches rebased onto the new release, and its CI has published a toolchain tarball for that rev.
  • During the rc period, test the new version via the "next" toolchain first: update go.toolchain.next.branch and run TS_GO_NEXT=1 ./pull-toolchain.sh, then let the optional go-next CI jobs find breakage before release day.

Toolchain switch

  • Update go.toolchain.branch to the new tailscale.goX.YY branch name.
  • Run ./pull-toolchain.sh. This updates:
    • go.toolchain.rev (and go.toolchain.next.rev if it fell behind)
    • go.toolchain.version
    • the go directive in go.mod
    • flakehashes.json (Nix SRI hashes, via tool/updateflakes)

Version strings elsewhere

  • README.md: "We always require the latest Go release, currently Go 1.NN".
  • .github/workflows/: grep for hardcoded Go versions. As of Go 1.27 the workflows use go-version-file: go.mod and need no changes, but rc-period pins (e.g. actions/setup-go with an explicit rc version) must be reverted if any were added.

Regenerate derived files

  • make updatedeps to regenerate all depaware.txt files. The new stdlib usually reshuffles internal dependencies.
  • Regenerate gzip assets if compress/flate output changed (it did in Go 1.27; the go generate steps embed compressed bytes and CI checks they are reproducible with the current toolchain):
    • tempfork/spf13/cobra: go generate ./...
    • util/eventbus: go generate ./... Use the new toolchain (./tool/go) on PATH when running these.

Things that may need attention

  • Static analysis: check that the golang.org/x/tools and staticcheck (honnef.co/go/tools) versions in go.mod support the new Go version, and bump them if needed (Go 1.26 needed a staticcheck bump). Verify with ./tool/go run ./cmd/tsvet.
  • go.mod / go.sum: run ./tool/go mod tidy and eyeball the diff; a new Go version can reorganize the file format or module graph pruning.
  • New-version breakage in our code or vendored deps: build and test everything (./tool/go build ./... && ./tool/go test ./...), including GOOS=darwin,windows,etc. cross-builds, before relying on CI.
  • The corp repo, Android, iOS, and other downstream repos have their own bumps; this checklist covers only this repo.

Behavior changes that have bitten us

Categories of Go release fallout seen in past bumps (mostly in corp, but the categories generalize); grep for them before blaming the code:

  • gofmt output can change; run gofmt -l across the tree (and corp) with the new toolchain and reformat (Go 1.27 reformatted two corp files).
  • encoding/json error strings and UnmarshalTypeError.Field can change. Tests asserting exact error text break, and so can third-party libraries: Go 1.27 reports the full path to the offending value ("errors.deletes.0") where earlier versions reported just the top-level field, which broke dnsimple-go's error-recovery gate (their PR #271).
  • Error identity from canceled streaming HTTP requests can change: Go 1.27's http2 surfaces the underlying "use of closed network connection" where Go 1.26 returned the context error. Prefer normalizing to ctx.Err() at the source (see sendMapRequest in control/controlclient) over teaching each test the new string.
  • json.Decoder over a reader that gains data after reporting EOF is not guaranteed to see the later writes; Go 1.27 stopped re-polling. Interleaved write-then-decode test helpers should read complete lines instead (corp tslogtest).
  • The race detector's cost profile can shift: Go 1.27's race mode made a reflection-heavy corp test several times slower, turning a slow-but-passing 70s test into a 10 minute timeout. Watch race job durations, not just pass/fail.

After the switch

  • Send the branch through full CI and fix what falls out; amend this checklist with anything new you discover.
  • Once the release is proven, consider a follow-up "use Go 1.NN things" cleanup commit (gofix modernizers, new stdlib APIs), kept separate from the mechanical bump.