Skip to content

Commit ef92894

Browse files
dev: reused exit codes (#2364)
1 parent 9cdc7af commit ef92894

File tree

6 files changed

+12
-7
lines changed

6 files changed

+12
-7
lines changed

Diff for: pkg/commands/cache.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/spf13/cobra"
99

1010
"github.com/golangci/golangci-lint/internal/cache"
11+
"github.com/golangci/golangci-lint/pkg/exitcodes"
1112
"github.com/golangci/golangci-lint/pkg/fsutils"
1213
"github.com/golangci/golangci-lint/pkg/logutils"
1314
)
@@ -51,7 +52,7 @@ func (e *Executor) executeCleanCache(_ *cobra.Command, args []string) {
5152
e.log.Fatalf("Failed to remove dir %s: %s", cacheDir, err)
5253
}
5354

54-
os.Exit(0)
55+
os.Exit(exitcodes.Success)
5556
}
5657

5758
func (e *Executor) executeCacheStatus(_ *cobra.Command, args []string) {
@@ -66,7 +67,7 @@ func (e *Executor) executeCacheStatus(_ *cobra.Command, args []string) {
6667
fmt.Fprintf(logutils.StdOut, "Size: %s\n", fsutils.PrettifyBytesCount(cacheSizeBytes))
6768
}
6869

69-
os.Exit(0)
70+
os.Exit(exitcodes.Success)
7071
}
7172

7273
func dirSizeBytes(path string) (int64, error) {

Diff for: pkg/commands/config.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,5 @@ func (e *Executor) executePathCmd(_ *cobra.Command, args []string) {
6464
}
6565

6666
fmt.Println(usedConfigFile)
67-
os.Exit(0)
67+
os.Exit(exitcodes.Success)
6868
}

Diff for: pkg/commands/help.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/fatih/color"
1010
"github.com/spf13/cobra"
1111

12+
"github.com/golangci/golangci-lint/pkg/exitcodes"
1213
"github.com/golangci/golangci-lint/pkg/lint/linter"
1314
"github.com/golangci/golangci-lint/pkg/logutils"
1415
)
@@ -93,5 +94,5 @@ func (e *Executor) executeLintersHelp(_ *cobra.Command, args []string) {
9394
fmt.Fprintf(logutils.StdOut, "%s: %s\n", color.YellowString(p), strings.Join(linterNames, ", "))
9495
}
9596

96-
os.Exit(0)
97+
os.Exit(exitcodes.Success)
9798
}

Diff for: pkg/commands/linters.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/fatih/color"
88
"github.com/spf13/cobra"
99

10+
"github.com/golangci/golangci-lint/pkg/exitcodes"
1011
"github.com/golangci/golangci-lint/pkg/lint/linter"
1112
)
1213

@@ -48,5 +49,5 @@ func (e *Executor) executeLinters(_ *cobra.Command, args []string) {
4849
color.Red("\nDisabled by your configuration linters:\n")
4950
printLinterConfigs(disabledLCs)
5051

51-
os.Exit(0)
52+
os.Exit(exitcodes.Success)
5253
}

Diff for: 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) {
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-
os.Exit(0)
22+
os.Exit(exitcodes.Success)
2223
}
2324

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

Diff for: pkg/config/reader.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/mitchellh/go-homedir"
1111
"github.com/spf13/viper"
1212

13+
"github.com/golangci/golangci-lint/pkg/exitcodes"
1314
"github.com/golangci/golangci-lint/pkg/fsutils"
1415
"github.com/golangci/golangci-lint/pkg/logutils"
1516
"github.com/golangci/golangci-lint/pkg/sliceutil"
@@ -87,7 +88,7 @@ func (r *FileReader) parseConfig() error {
8788

8889
if r.cfg.InternalTest { // just for testing purposes: to detect config file usage
8990
fmt.Fprintln(logutils.StdOut, "test")
90-
os.Exit(0)
91+
os.Exit(exitcodes.Success)
9192
}
9293

9394
return nil

0 commit comments

Comments
 (0)