Skip to content

Commit d23a1f0

Browse files
committed
feat: send error output to stderr
1 parent 341fd32 commit d23a1f0

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

main.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func handleLine(input string) {
3131
if isCamelCaseAllowNumbers(parts[0]) {
3232
fmt.Printf("Success: Variable %s is camel case.\n", parts[0])
3333
} else {
34-
fmt.Printf("Error: Variable %s is not camel case.\n", parts[0])
34+
fmt.Fprintf(os.Stderr, "Error: Variable %s is not camel case.\n", parts[0])
3535
isErrorDetected = true
3636
}
3737
return
@@ -41,7 +41,7 @@ func handleLine(input string) {
4141
if isCamelCaseAllowNumbers(parts[0]) {
4242
fmt.Printf("Success: Variable %s is camel case.\n", parts[0])
4343
} else {
44-
fmt.Printf("Error: Variable %s is not camel case.\n", parts[0])
44+
fmt.Fprintf(os.Stderr, "Error: Variable %s is not camel case.\n", parts[0])
4545
isErrorDetected = true
4646
}
4747
return
@@ -66,7 +66,7 @@ func processFile(fileName string) int {
6666
fmt.Printf("\nReading file: %s\n", fileName)
6767
file, err := os.Open(fileName)
6868
if err != nil {
69-
fmt.Printf("Error reading file: %s.\n", err.Error())
69+
fmt.Fprintf(os.Stderr, "Error reading file: %s.\n", err.Error())
7070
return 1
7171
}
7272

@@ -77,7 +77,7 @@ func processFile(fileName string) int {
7777
}
7878

7979
if err := scanner.Err(); err != nil {
80-
fmt.Printf("Error scanning file: %s.\n", err.Error())
80+
fmt.Fprintf(os.Stderr, "Error scanning file: %s.\n", err.Error())
8181
isErrorDetected = true
8282
}
8383

@@ -113,15 +113,15 @@ func main() {
113113
})
114114

115115
if errorCounter > 0 {
116-
fmt.Printf("Coding standards not met.\n")
116+
fmt.Fprintf(os.Stderr, "Coding standards not met.\n")
117117
os.Exit(1)
118118
} else {
119119
fmt.Printf("No coding standards violation detected.\n")
120120
os.Exit(0)
121121
}
122122

123123
if err != nil {
124-
fmt.Printf("Error in batch processing: %v \n", err)
124+
fmt.Fprintf(os.Stderr, "Error in batch processing: %v \n", err)
125125
os.Exit(1)
126126
}
127127

0 commit comments

Comments
 (0)