Skip to content

fix(go): skip modules a replace directive names - #175

Merged
sweepies merged 3 commits into
mainfrom
feat/go-origins
Nov 4, 2026
Merged

sweepies merged 3 commits into
mainfrom
feat/go-origins

Conversation

@sweepies

@sweepies sweepies commented Nov 4, 2026 •

Copy link
Copy Markdown
Owner

Sixth per-ecosystem fix from the registry audit, after Bundler (#168), Composer (#170), NuGet (#171), Maven/Gradle (#173) and Cargo (#174).

Why Go differs

A Go module path names the place its code is served from. proxy.golang.org fetches a module from that origin, so it can't serve someone else's code under a private path, and dependency confusion as in npm or PyPI can't happen. What private modules risk is their path reaching the proxy in a lookup. Which paths are private is GOPRIVATE in the environment, which no committed file sets, so the Count can't tell. The docs now say so.

What committed files can do: replace

A module that a replace directive names doesn't come from its requirement: the build uses the replacement. Updating such a requirement is pointless at best. Past a version-specific replacement (X v1.2.3 => git.acme.dev/fork v1.2.4) it moves the build off the fork and onto upstream.

  • A module a replace names, in go.mod or in a go.work in its folder or above, is listed as skipped with the reason. That covers block or single directives, quoted paths, and any version.
  • A replace the Count can't read, or an unreadable go.work, fails every lookup of that module.
  • go.work is read whatever files and exclude select. A symlinked one counts as unreadable.

An existing test that expected a replaced module to be extracted now expects it to be skipped.

Follow-ups

  • GOPRIVATE, GONOPROXY and GOPROXY from the environment, or an operator setting naming private module prefixes, could keep private paths from reaching the proxy. Not done here.

View guided diff Turn on auto-fix

A module a replace directive names, in go.mod or a go.work in its folder
or above, is not what its requirement says: the build uses the
replacement. Updating its requirement past a version-specific replace
would move the build off the replacement onto the upstream module. Such
modules are now listed as skipped with the reason. A replace directive or
go.work the Count cannot read fails every lookup of that module, and
go.work is read whatever files and exclude select.

Module paths name where their code is served from, so the module proxy
cannot serve someone else's code under a private path; which paths are
private is GOPRIVATE in the environment, which the docs now say.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
count-patchula a8b7af1 Commit Preview URL

Branch Preview URL
Nov 04 2026, 03:59 AM

In workspace mode Go merges the replace directives of every module the
go.work uses, and takes the workspace's own modules from their folders.
Requirements on either are now skipped as well; the go.mod files a
go.work uses are read in the follow-up pass, and a use the Count cannot
resolve or a used go.mod it cannot read fails every lookup of the
module.
The real-tool test of a targeted Go update replaced its module with a
local folder to stay offline, and the Count now skips replaced modules.
The fixture now serves the module from a GOPROXY=file:// proxy it writes
(list, info, go.mod and a stored zip per version), so real go get moves
an ordinary requirement.
@sweepies
sweepies merged commit 8739811 into main Nov 4, 2026
11 checks passed
@sweepies
sweepies deleted the feat/go-origins branch November 4, 2026 04:21
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.

1 participant