-
Notifications
You must be signed in to change notification settings - Fork 20.6k
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
build: simplify go mod tidy check #31266
Conversation
I think we can just use the that would much better. |
I agree it's better to use One thing we can do, is fold the check into the generated files check. go.mod/go.sum are kind of like generated files anyway. |
build/ci.go
Outdated
if updates := build.DiffHashes(hashes, tidied); len(updates) > 0 { | ||
log.Fatalf("files changed on running 'go mod tidy': %v", updates) | ||
} | ||
build.MustRun(new(build.GoToolchain).Go("mod", "tidy", "-diff")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The diff will be printed on the Stdout
and Stderr
, but the output is not checked?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It exits with a non-zero code if the diff is not empty.
It's simple and can print necessary information as well.
ref:
https://go.dev/ref/mod#go-mod-tidy:~:text=The%20%2Ddiff%20flag%20causes
https://go.dev/doc/go1.23#:~:text=The%20new%20go%20mod%20tidy%20%2Ddiff