Skip to content

Latest commit

 

History

History
26 lines (19 loc) · 470 Bytes

printf-const.md

File metadata and controls

26 lines (19 loc) · 470 Bytes

Format Strings outside Printf

If you declare format strings for Printf-style functions outside a string literal, make them const values.

This helps go vet perform static analysis of the format string.

BadGood
msg := "unexpected values %v, %v\n"
fmt.Printf(msg, 1, 2)
const msg = "unexpected values %v, %v\n"
fmt.Printf(msg, 1, 2)