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: add a '-go' flag to 'go mod tidy' #45094

Closed
bcmills opened this issue Mar 17, 2021 · 4 comments
Closed

cmd/go: add a '-go' flag to 'go mod tidy' #45094

bcmills opened this issue Mar 17, 2021 · 4 comments
Labels
FrozenDueToAge modules NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@bcmills
Copy link
Contributor

bcmills commented Mar 17, 2021

I've been considering the migration paths for lazy loading (#36460).

When lazy loading lands, if users merely run go mod edit -go=1.17 and then go build, the build will in many cases fail due to missing transitive dependencies: Go 1.16 modules don't necessarily already satisfy the lazy loading invariants. Similarly, if users instead run go mod edit -go=1.17 && go mod tidy, they may find that the selected versions of transitive dependencies have changed: relevant transitive requirements that were previously implicit may be pruned out entirely by lazy loading.

To ease the transition, I suggest that we add a -go flag to go mod tidy. It would function analogous to the -go flag to go mod tidy, as go mod tidy -go=1.17. Specifically, it would cause go mod tidy to:

  1. Load the existing module dependency graph according to whatever go version is already present in the go.mod file.
  2. Load the all package pattern per the go version indicated by the -go flag, using the module graph from (1).
  3. Then, write tidy go.mod and go.sum files with the go version indicated by the -go flag, recording the dependencies used in (2).

The implementation work for this approach would be fairly minimal, and it would allow users to adopt lazy loading without any changes to the selected versions of relevant modules.

CC @jayconrod @matloob @rsc

@bcmills bcmills added NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. modules labels Mar 17, 2021
@bcmills bcmills added this to the Go1.17 milestone Mar 17, 2021
@bcmills bcmills self-assigned this Mar 17, 2021
@bcmills bcmills added the NeedsFix The path to resolution is known, but the work has not been done. label Apr 6, 2021
@bcmills bcmills changed the title cmd/go: add a '-go' flag to 'go mod tidy'? cmd/go: add a '-go' flag to 'go mod tidy' Apr 6, 2021
@gopherbot gopherbot removed the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Apr 6, 2021
@ianlancetaylor
Copy link
Contributor

Is this going to happen for 1.17?

@bcmills
Copy link
Contributor Author

bcmills commented Apr 27, 2021

Yes, I still plan to get this in for 1.17. (It should be a small change, and makes the migration path much smoother for #36460.)

@gopherbot
Copy link

Change https://golang.org/cl/315210 mentions this issue: cmd/go: smoothe out upgrade paths for lazy loading

@gopherbot
Copy link

Change https://golang.org/cl/321069 mentions this issue: cmd/go/internal/modcmd: factor out a type for flags whose arguments are Go versions

gopherbot pushed a commit that referenced this issue May 24, 2021
…re Go versions

For #46141
Updates #45094

Change-Id: I6553600c69273762a81795ef021c66f4e0872b6b
Reviewed-on: https://go-review.googlesource.com/c/go/+/321069
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
@golang golang locked and limited conversation to collaborators May 18, 2022
@rsc rsc unassigned bcmills Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge modules NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants