Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upcmd/go: add mod tidy -check #27005
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
mvdan
Aug 15, 2018
Member
Non-zero exit codes are usually for errors, so having it behave like this by default would be counter-intuitive.
Perhaps it could have something similar to gofmt, which has the -l and -d flags to tell if any changes were made.
|
Non-zero exit codes are usually for errors, so having it behave like this by default would be counter-intuitive. Perhaps it could have something similar to gofmt, which has the |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
swtch1
Aug 15, 2018
If the files are successfully added why wouldn't you want to see a 0 status code? This means that the following script would fail:
#!/usr/bin/env bash
set -e
go mod tidy # <-- non 0 return code
echo 'we never get here'
swtch1
commented
Aug 15, 2018
|
If the files are successfully added why wouldn't you want to see a 0 status code? This means that the following script would fail: #!/usr/bin/env bash
set -e
go mod tidy # <-- non 0 return code
echo 'we never get here' |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
fishy
Aug 15, 2018
That makes sense. How about maybe make it optional? e.g. when it's executed with a flag it should return non-zero when it made any changes.
fishy
commented
Aug 15, 2018
•
|
That makes sense. How about maybe make it optional? e.g. when it's executed with a flag it should return non-zero when it made any changes. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
thepudds
commented
Aug 15, 2018
|
@gopherbot, please add label modules |
gopherbot
added
the
modules
label
Aug 15, 2018
rsc
changed the title from
modules: `go mod tidy` should return non-zero when it made changes to go.mod and/or go.sum files
to
cmd/go: add mod tidy -check
Aug 18, 2018
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
rsc
Aug 18, 2018
Contributor
We could think about adding a flag that means "don't do the update, but fail if one is needed".
Not sure exactly what to call it but I put -check in the description. Needs more thought.
|
We could think about adding a flag that means "don't do the update, but fail if one is needed". |
fishy commentedAug 15, 2018
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version)?go version go1.11rc1 darwin/amd64Does this issue reproduce with the latest release?
N/A
What operating system and processor architecture are you using (
go env)?What did you do?
go.modandgo.sumfilesgo mod tidyto add them backWhat did you expect to see?
go mod tidyshould return non-zero as it made changes. This way it could be integrated to tools like pre-commit hooks to make sure that we don't commit untidiedgo.modandgo.sumfiles into version controlWhat did you see instead?
go mod tidyreturned zero