Skip to content

cmd/go: readonly does not affect all go mod sub-commands #26850

Closed
@dsnet

Description

@dsnet

Using go.11beta3

In https://golang.org/cl/127916, I'm working a test.bash script that is intended to be used a pre-submit and post-submit hook. In that script, I rely on go mod tidy and go mod vendor to manage dependencies (I use "vendor" so that I can use the same set of dependencies when testing with Go1.9 and Go1.10).

One of the properties of the test.bash script is the ability to detect when the go.mod and go.sum files are out of sync with the source code (e.g., a user submitted code that changed the dependency tree but forgot to also submit the updated go.mod file).

Currently, since -mod=readonly does not affect go mod tidy or go mod vendor, I need to shell out to git diff to check whether the go.mod or go.sum files were altered. I would have expected -mod=readonly to affect "tidy" and "vendor" in a way such that:

  • If the current files on disk are exactly what it would have outputted, it does nothing
  • If they would have had to make changes, they would fail with a non-zero error code.

\cc @bcmills

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.modules

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions