Repository navigation
gomodfs: add go.mod copies to golang.org/toolchain modules - #35
Merged
Merged
Conversation
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
tomhjp
approved these changes
Oct 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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