-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
fix: exit early on run --version #3067
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
Conversation
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.
LGTM!
Do you know what change made the command not exit successfully after returning nil
? Just pondering if it's worth adding some details to why we have to do this
It's because the version is displayed inside the preRun so a |
"github.com/golangci/golangci-lint/pkg/logutils" | ||
) | ||
|
||
func (e *Executor) persistentPreRun(_ *cobra.Command, _ []string) error { | ||
if e.cfg.Run.PrintVersion { | ||
_, _ = fmt.Fprintf(logutils.StdOut, "golangci-lint has version %s built from %s on %s\n", e.version, e.commit, e.date) | ||
return nil | ||
os.Exit(exitcodes.Success) // a return nil is not enough to stop the process because we are inside the `preRun`. |
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.
heh, I wondered why we did a return instead of just an exit here :)
Fixes #3066