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