Stop Downgrading Go Just to Run `go mod ...

Stop Downgrading Go Just to Run `go mod tidy`

May 05, 2026

Quick tip: running go mod tidy on backport branches without downgrading your local Go (e.g. local Go 1.26 vs branch using Go 1.25).

Even though newer Go versions are generally backward compatible for builds, go mod tidy can produce different go.mod / go.sum outputs depending on the toolchain version. For backport branches, it’s safer to run tidy using the Go version expected by that branch.

You can use a containerized Go toolchain instead:

    docker run --rm -it \
      -v "$PWD":/workspace \
      -w /workspace \
      golang:1.25.8 \
      sh -lc 'cd <your-module-path> && /usr/local/go/bin/go mod tidy'

This mounts your repo, runs tidy with the correct Go version, and keeps your local environment untouched.

¿Te gusta esta publicación?

Comprar Oscar | Creator of StreamVault un café

Más de Oscar | Creator of StreamVault