-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
x/tools/go/analysis/passes/fieldalignment/cmd: document exit codes #57091
Comments
Exit code 3 most likely comes from
I think this comes down to whether we think we should document the exit codes within cc @adonovan |
I suggest you use the -json flag, which cause the tool to exit zero and report its diagnostics and fixes in a machine-readable form. You don't need to read them, but it solves the exit code problem.
BTW I'm curious why you would want to apply fieldalignment to code you plan to bundle. The fixes applied by fieldalignment should be reviewed, since in some cases they may degrade performance and they can certainly cause tests that rely on field order (via reflection) to fail. |
@adonovan Thanks for letting me know. That library ( I didn't know about the potential for performance degradation (negative). Do you think I should avoid using the |
'It depends" is always the answer to this kind of question; the only way to know for sure is to measure it. My main concern is that you should "ship the bits you test", which means you should't blindly apply a transformation from any static analysis tool without review and testing. |
Thanks for letting me know. The bundle is tested and analyzed in the CICD workflow. |
Context
https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/fieldalignment
Usecase
Using https://github.com/switchupcb/disgo/blob/v10/_gen/bundle/main.go#L80
fieldalignment -fix
returns an exit code 3.go/exec Command Run
.fieldalignment Stdout
shows that structs were fixed.fieldalignment -fix
again twice more fixes things (fixes https://github.com/switchupcb/disgo/blob/v10/wrapper/json_unmarshal.go#L186)Sure, I can fix it in the developer version. However, I'm still unaware of what exit code 3 is.
Code
Add the meaning of the exit codes for fieldalignment to
fieldalignment -help
or somewhere.The text was updated successfully, but these errors were encountered: