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 mod tidy' mode that only verifies whether changes are needed #27682

Closed
bcmills opened this issue Sep 14, 2018 · 4 comments
Closed
Labels
FeatureRequest FrozenDueToAge modules NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@bcmills
Copy link
Contributor

bcmills commented Sep 14, 2018

Maintainers of large projects will often want to ensure that their module definitions are both complete and minimal at commit time (example: #27643 (comment)).

go mod tidy is the obvious command to verify that a definition is complete and minimal, but it makes changes even when -mod=readonly is set (#26850). As far as I am aware, there is no way to verify (nondestructively) that a definition is minimal — only that it is complete (go list all -mod=readonly), and even then only subject to the current GOOS, GOARCH, and build tags.

If we decide not to change the behavior of go mod tidy -mod=readonly, I think it's important that we provide some other command that would be suitable for use in a commit hook (along the lines of gofmt -l).

@bcmills bcmills added NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. FeatureRequest modules labels Sep 14, 2018
@bcmills bcmills added this to the Go1.12 milestone Sep 14, 2018
@kaedys
Copy link

kaedys commented Sep 14, 2018

I rather like the idea of simply adding the -l flag to go mod tidy and have it work the exact same as it does for gofmt (ie. doesn't modify the source files, instead printing out where it would have).

@rsc
Copy link
Contributor

rsc commented Sep 26, 2018

go mod tidy -n seems fine. (The go command already uses -n for these things.)

@rsc rsc added the NeedsFix The path to resolution is known, but the work has not been done. label Sep 26, 2018
@gopherbot gopherbot removed the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Sep 26, 2018
@rsc
Copy link
Contributor

rsc commented Sep 26, 2018

Dup of #27005?

@bcmills
Copy link
Contributor Author

bcmills commented Oct 4, 2018

Dup of #27005?

Yep, looks like it.

@bcmills bcmills closed this as completed Oct 4, 2018
@golang golang locked and limited conversation to collaborators Oct 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FeatureRequest 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

4 participants