Skip to content

Commit 7cf0f35

Browse files
authored
Add a linter to catch fmt.Print* (#4782)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a new linter for improved logging practices. - **Bug Fixes** - Removed unnecessary `fmt` package usage to streamline output. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 71a58d9 commit 7cf0f35

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

.golangci.yml

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ linters-settings:
77
desc: "logging is allowed only by zerolog"
88
dupl:
99
threshold: 100
10+
forbidigo:
11+
forbid:
12+
- 'fmt\.Print.*' # This will catch Printf, Println, Print
1013
funlen:
1114
lines: 100
1215
statements: 100
@@ -70,6 +73,7 @@ linters:
7073
- dogsled
7174
- errcheck
7275
- copyloopvar
76+
- forbidigo
7377
- funlen
7478
- gochecknoinits
7579
- goconst

main.go

-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package main
22

33
import (
44
"context"
5-
"fmt"
65
"os"
76
"os/signal"
87

@@ -97,7 +96,4 @@ func main() {
9796
// Wait for the context to be cancelled
9897
// either by a signal or by the command completing
9998
<-localCtx.Done()
100-
101-
// Print a newline to ensure the next prompt is on a new line
102-
fmt.Println()
10399
}

pkg/config/types/gen/generate.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ import (
1616

1717
func main() {
1818
if len(os.Args) != 2 {
19-
fmt.Println("Please provide the path to the config directory.")
20-
os.Exit(1)
19+
log.Fatal("Please provide the path to the config directory")
2120
}
2221
pkgPath := os.Args[1]
2322

0 commit comments

Comments
 (0)