From 552ff80489be63faf10aa097034bdf49acd8e17a Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Fri, 5 Aug 2022 15:49:22 +0200 Subject: [PATCH] fix: exit early on run --version (#3067) --- pkg/commands/root.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/commands/root.go b/pkg/commands/root.go index 8ab119608dc7..cc5a78dd8d9a 100644 --- a/pkg/commands/root.go +++ b/pkg/commands/root.go @@ -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)