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

Open
bcmills opened this issue Mar 17, 2021 · 0 comments
Open

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

bcmills opened this issue Mar 17, 2021 · 0 comments
Assignees
Labels
Milestone

Comments

@bcmills
Copy link
Member

@bcmills 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 this to the Go1.17 milestone Mar 17, 2021
@bcmills bcmills self-assigned this Mar 17, 2021
@bcmills bcmills added the NeedsFix 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 label Apr 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants