如果你在函数外声明Printf-style 函数的格式字符串,请将其设置为const常量。
这有助于go vet对格式字符串执行静态分析。
Bad | Good |
---|---|
msg := "unexpected values %v, %v\n" fmt.Printf(msg, 1, 2) |
const msg = "unexpected values %v, %v\n" fmt.Printf(msg, 1, 2) |
如果你在函数外声明Printf-style 函数的格式字符串,请将其设置为const常量。
这有助于go vet对格式字符串执行静态分析。
Bad | Good |
---|---|
msg := "unexpected values %v, %v\n" fmt.Printf(msg, 1, 2) |
const msg = "unexpected values %v, %v\n" fmt.Printf(msg, 1, 2) |