Skip to content

Commit da3b149

Browse files
authored
fix: exit early on run --version (#3067)
1 parent d4fd2db commit da3b149

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pkg/commands/root.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@ import (
1212
"github.com/spf13/pflag"
1313

1414
"github.com/golangci/golangci-lint/pkg/config"
15+
"github.com/golangci/golangci-lint/pkg/exitcodes"
1516
"github.com/golangci/golangci-lint/pkg/logutils"
1617
)
1718

1819
func (e *Executor) persistentPreRun(_ *cobra.Command, _ []string) error {
1920
if e.cfg.Run.PrintVersion {
2021
_, _ = fmt.Fprintf(logutils.StdOut, "golangci-lint has version %s built from %s on %s\n", e.version, e.commit, e.date)
21-
return nil
22+
os.Exit(exitcodes.Success) // a return nil is not enough to stop the process because we are inside the `preRun`.
2223
}
2324

2425
runtime.GOMAXPROCS(e.cfg.Run.Concurrency)

0 commit comments

Comments
 (0)