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

Comments

Projects
None yet
4 participants
@bcmills
Copy link
Member

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).

@kaedys

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Contributor

commented Sep 26, 2018

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

@rsc rsc added the NeedsFix label Sep 26, 2018

@rsc

This comment has been minimized.

Copy link
Contributor

commented Sep 26, 2018

Dup of #27005?

@bcmills

This comment has been minimized.

Copy link
Member Author

commented Oct 4, 2018

Dup of #27005?

Yep, looks like it.

@bcmills bcmills closed this Oct 4, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.