Skip to content

Commit

Permalink
fix: exit early on run --version (golangci#3067)
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez authored and SeigeC committed Apr 4, 2023
1 parent ced8f57 commit 552ff80
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/commands/root.go
Expand Up @@ -12,13 +12,14 @@ import (
"github.com/spf13/pflag"

"github.com/golangci/golangci-lint/pkg/config"
"github.com/golangci/golangci-lint/pkg/exitcodes"
"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`.
}

runtime.GOMAXPROCS(e.cfg.Run.Concurrency)
Expand Down

0 comments on commit 552ff80

Please sign in to comment.