Repository navigation
fix(go): skip modules a replace directive names - #175
Merged
Merged
Conversation
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.
Deploying with
|
| 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.
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.
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
GOPRIVATEin the environment, which no committed file sets, so the Count can't tell. The docs now say so.What committed files can do:
replaceA module that a
replacedirective 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.replacenames, ingo.modor in ago.workin its folder or above, is listed as skipped with the reason. That covers block or single directives, quoted paths, and any version.replacethe Count can't read, or an unreadablego.work, fails every lookup of that module.go.workis read whateverfilesandexcludeselect. 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,GONOPROXYandGOPROXYfrom the environment, or an operator setting naming private module prefixes, could keep private paths from reaching the proxy. Not done here.