Go

Go

Made by DeepSource

Printf-like function without f suffix GO-W6006

Bug risk
Major

For Printf-like functions they should be named correctly so that consumers of the function use it correctly. It is recommended to use f as suffix for such functions to make it clear that arguments are preceded with format specifier.

Bad practice

func glog(format string, args ...any) {
    log.Printf("glog " + format, args...)
}

func dump(w io.Writer, prefix, format string, args ...any) {
    fmt.Fprintf(w, "dump " + format, args...)
}

Recommended

func glogf(format string, args ...any) {
    log.Printf("glog " + format, args...)
}

func dumpf(w io.Writer, prefix, format string, args ...any) {
    fmt.Fprintf(w, "dump " + format, args...)
}