-
Notifications
You must be signed in to change notification settings - Fork 17.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
cmd/vet: fix documentation of go vet error code #24477
Comments
Change https://golang.org/cl/101876 mentions this issue: |
@ad-si Confirmed. Thanks for your report. I sent a CL for fixing the docs. |
Are we positive that the code is right and the docs are wrong? In general, I'd assume that the docs are right; exit code 2 when invoking a tool in the incorrect way is what you would expect. |
@mvdan No, I think you would expect that if a program fails it returns 1. That's what most cli tools do. |
By invoking a tool incorrectly, I mean cases such as bad flags and incorrect arguments. For example:
This particular case seems in line with the doc you quote above. |
Uhm, then there is something fundamentally wrong.
|
I agree that this is a bit confusing. The docs could technically be right, because what you got there isn't vet problems being reported, rather errors when loading and type-checking the program. And this can be useful; if vet returns code 2, it didn't function properly. If it returns 1, it ran properly and found some issues. And if it returns 0, it ran properly and found no issues. I assume that it's a bit late to change this behavior, since people could depend on it. Perhaps the docs could be clarified, to avoid confusion. /cc @robpike who originally wrote the docs in question. |
Ahhh, I should actually be running |
@ad-si, those are actually compile errors rather than vet errors. For example, if you run We should probably make this exit 1 so it's consistent with vet errors and the documentation. But, also, let's not overthink this. :) |
New proposal: the tools really aren't trying to convey information beyond "success" or "failure" and it's not worth the effort to try to distinguish types of failure because approximately nobody cares about which non-zero status it exited with, so let's just change the documentation to say "zero" and "non-zero". |
Uhm, I care (a lot). If |
Change https://golang.org/cl/101918 mentions this issue: |
@ad-si, this is the first time vet crashing has been mentioned. Could you clarify your use case? |
We're running However, if the program itself crashes, my build pipeline is obviously broken and I need to fix it. |
Perhaps I'm still unclear. If I would certainly hope vet crashes aren't something that happen regularly enough that you need special tooling around them. |
Well, there is no human in the loop. That's the point =D.
Could also mean that
Well, I'd certainly hope so too, but I work in software quality / security, and folks have hoped many things ;-) |
Maybe there’s a misunderstanding of “crash” vs “exit with a non-zero error code.” A crash would mean a panic, segfault, etc. Are you seeing crashes? What do they look like? |
Yeah, it shouldn't crash, but it's not guaranteed. So I need to handle the case that it crashes in unforeseeable ways, although it hasn't happened to me yet. |
If https://go-review.googlesource.com/c/go/+/101918 would land this would be taken care of. Ping @aclements |
Closing. This was fixed long ago by CL 147018. |
Following documentation seems to be switched.
As far as I can see go vet returns 1 on program errors and 2 if issues were found in the checked code.
go/src/cmd/vet/doc.go
Lines 22 to 23 in 0c0aed3
The text was updated successfully, but these errors were encountered: