
What?
A linter replacing variadic formatting functions with their non variadic equivalent, example:
fmt.Printf("Some error: %v", err)
becomes fmt.Print("Some error: ", err)
There are some interesting edge cases, for example testing.T.Fatal
behaves differently than log.Fatal
because the former calls fmt.Sprintln
while the latter fmt.Sprint
.
Why?
The main reason is for consistency across a code base.
Also, variadic functions are very marginally faster: see benchmark.
Use
To display the errors:
linter [path to directory containing Go package]
To fix the file in place (make sure to have a backup of the files):
linter -w [path to directory containing Go package]