gofmtprintlinter
gofmtprintlinter is a static analysis tool to detect fmt.Print or fmt.Println or fmt.Printf.
package main
import "fmt"
func main() {
fmt.Print("Hello, world!") // detect this
fmt.Println("Hello, world!") // detect this
fmt.Printf("Hello, world!") // detect this
}
You can add an ignore comment so that 'gofmtprintlinter' is not detected
package main
import "fmt"
func main() {
//lint:ignore gofmtprintlinter ignore
fmt.Print("Hello, world!") // don't detect this by ignore comment
}
Install
go install github.com/olibaa/gofmtprintlinter/cmd/gofmtprintlinter@latest
Usage
check for specific packages
gofmtprintlinter [Directory Path]
check all packages
gofmtprintlinter ./...
Ignore Generated File
Specify -ignore-gen-file and -generated-comment as options.
Ignore the generated file with the -ignore-gen-file option.
For the -generated-comment option, enter a comment that can be identified as a Generate File.
gofmtprintlinter -ignore-gen-file -generated-comment="Generated File Comment" ./...
The default for the -generated-comment option is "Code generated by".
If the "-generated-comment" option is not specified, the default value will be used.
gofmtprintlinter -ignore-gen-file ./...
License
License