Skip to content

gomodfs: add go.mod copies to golang.org/toolchain modules - #35

Merged
bradfitz merged 1 commit into
mainfrom
bradfitz/toolchain
Oct 21, 2026
Merged

bradfitz merged 1 commit into
mainfrom
bradfitz/toolchain

Conversation

@bradfitz

Copy link
Copy Markdown
Member

Go toolchain zips (https://go.dev/doc/toolchain) ship their go.mod
files renamed to _go.mod so the module zip has no nested modules.
After downloading one, cmd/go copies each _go.mod back to go.mod in
the module cache, chmodding each directory writable first. On gomodfs
that fails, breaking GOTOOLCHAIN switching:

go: download go1.27.1: chmod /home/ubuntu/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.27.1.linux-amd64/src/cmd: read-only file system

cmd/go skips that step if src/go.mod already exists with the same size
as src/_go.mod, so when storing a golang.org/toolchain module, add a
go.mod copy beside each _go.mod. The ziphash is still computed from
the original zip and matches sum.golang.org.

Toolchains already in a store lack the copies, so if a cached one has
no src/go.mod, download it again (unless FS.ReadOnly).

The binaries' exec bits already come through from the zip, so cmd/go's
other post-download fixup (chmod +x) was already skipped.

Updates tailscale/corp#50265

Go toolchain zips (https://go.dev/doc/toolchain) ship their go.mod
files renamed to _go.mod so the module zip has no nested modules.
After downloading one, cmd/go copies each _go.mod back to go.mod in
the module cache, chmodding each directory writable first. On gomodfs
that fails, breaking GOTOOLCHAIN switching:

    go: download go1.27.1: chmod /home/ubuntu/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.27.1.linux-amd64/src/cmd: read-only file system

cmd/go skips that step if src/go.mod already exists with the same size
as src/_go.mod, so when storing a golang.org/toolchain module, add a
go.mod copy beside each _go.mod. The ziphash is still computed from
the original zip and matches sum.golang.org.

Toolchains already in a store lack the copies, so if a cached one has
no src/go.mod, download it again (unless FS.ReadOnly).

The binaries' exec bits already come through from the zip, so cmd/go's
other post-download fixup (chmod +x) was already skipped.

Updates tailscale/corp#50265

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
Change-Id: I429d28a73b50bc60e2ad4fda22075f3013f1f9f8
@bradfitz
bradfitz requested a review from tomhjp October 20, 2026 17:49
@bradfitz
bradfitz merged commit 954c541 into main Oct 21, 2026
7 checks passed
@bradfitz
bradfitz deleted the bradfitz/toolchain branch October 21, 2026 10:27
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.

2 participants