Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: allow local replacements without a corresponding explicit requirement? #33370

Open
bcmills opened this issue Jul 30, 2019 · 3 comments
Open
Labels
modules NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.
Milestone

Comments

@bcmills
Copy link
Contributor

bcmills commented Jul 30, 2019

In CL 153157, I added code so that a module path that has a replace directive resolves to a pseudo-version of the form vX.0.0-00010101000000-000000000000 rather than checking for upstream dependencies.

That unblocks builds, but means that the module graph may indicate a commit that doesn't actually exist. There are use-cases for such a configuration, such as testing against unpublished commits of upstream modules (see #26241 (comment) and #32776), but since the commit does not actually exist, the requirement graph of the resulting module cannot be used without a corresponding replace directive in every downstream consumer.

Since this pseudo-version has an unambiguous and very unique commit hash (all zeroes!), I propose that we special-case it (if unreplaced) and treat it as equivalent to an empty commit.

CC @jayconrod @thepudds @rogpeppe

@bcmills bcmills added NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. modules labels Jul 30, 2019
@bcmills bcmills added this to the Go1.14 milestone Jul 30, 2019
@rsc rsc modified the milestones: Go1.14, Backlog Oct 9, 2019
@bcmills
Copy link
Contributor Author

bcmills commented Oct 15, 2019

Thinking about this some more, I think using the zero-version was a mistake.

Instead, we shouldn't be writing the require directive out at all: we don't know any valid version to require, and if a downstream consumer requires our module they're better off resolving latest instead.

That seems to support the second case considered in #26344 (comment): this sort of wildcard replace directive effectively means “select the latest version (none), and then select this replacement as if it were a slightly-higher version.”

@gopherbot
Copy link

Change https://golang.org/cl/220080 mentions this issue: design/36460: add design for lazy module loading

gopherbot pushed a commit to golang/proposal that referenced this issue Mar 5, 2020
Updates golang/go#36460
Updates golang/go#27900
Updates golang/go#26955
Updates golang/go#30831
Updates golang/go#32058
Updates golang/go#32380
Updates golang/go#32419
Updates golang/go#33370
Updates golang/go#33669
Updates golang/go#36369

Change-Id: I1d4644e3e8b4e688c2fc5a569312495e5072b7d7
Reviewed-on: https://go-review.googlesource.com/c/proposal/+/220080
Reviewed-by: Russ Cox <rsc@golang.org>
@bcmills bcmills modified the milestones: Go1.15, Backlog Apr 28, 2020
@bcmills bcmills changed the title cmd/go: treat pseudo-version 'vX.0.0-00010101000000-000000000000' as equivalent to an empty commit cmd/go: do not record required versions for modules resolved by local replacements Jun 16, 2020
@bcmills
Copy link
Contributor Author

bcmills commented Apr 13, 2021

That seems to support the second case considered in #26344 (comment): this sort of wildcard replace directive effectively means “select the latest version (none), and then select this replacement as if it were a slightly-higher version.”

Thinking about this further: it is often useful (for testing) to be able to slot in dormant replace directives and then run various go get commands to see what happens. As of Go 1.16 go get correctly mixes in the replacement versions, so that actually provides a fairly high-fidelity simulation of what would happen after the replaced versions are published.

So I think this sort of “select-and-replace” form should actually have a different syntax; perhaps one derived from (or identical to) the “replacement alias” form (#26904).

@bcmills bcmills changed the title cmd/go: do not record required versions for modules resolved by local replacements cmd/go: allow local replacements without a corresponding explicit requirement? Apr 13, 2021
@rsc rsc unassigned bcmills Jun 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
modules NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.
Projects
None yet
Development

No branches or pull requests

3 participants