Skip to content

cmd/go: add a 'go mod tidy' mode that only verifies whether changes are needed #27682

Closed
@bcmills

Description

@bcmills

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureRequestIssues asking for a new feature that does not need a proposal.FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.modules

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions