x/tools/cmd/goimports: return non-zero exit code if there's an offense #39032
Labels
FrozenDueToAge
NeedsFix
The path to resolution is known, but the work has not been done.
Tools
This label describes issues relating to any tools in the x/tools repository.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
This is more of a feature request (or question) rather than bug reporting. I'm trying to check formatting of go files with
goimports
which works as expected, but if there's any offensive file it always exit with code0
. As a result I need to hack around withtee
and similar tools to manually fail mymake checkfmt
target on CI.I was wondering if this was by design or any specific reasons not to return non-zero exit code on list (
-l
). I briefly looked around and it seems there might be a really easy way to add this, something like adding:if *list { fmt.Fprintln(out, filename) + exitCode = 1 # or any other reasonable exit code }
right after line 156, here:
https://github.com/golang/tools/blob/a4cde3673cf4d442ef00a2df0d7a6f707d9e726b/cmd/goimports/goimports.go#L155-L157
The text was updated successfully, but these errors were encountered: