Radar · Go · Archive · Week 46 · Nov 10 – 16, 2025
cmd/vet: add check for using %q with non‑{rune,byte} integer types
Worth knowingtooling
- What changed
go vetnow warns when the%qverb is used with an integer type that is notruneorbyte.- Production impact
- The source does not say.
- Try it
- Run
go veton a file that containsfmt.Printf("%q", 123)and observe the new warning. - Source
- github.com/golang/go/issues/72850
Understand it, then run it
go vet now checks the %q verb in fmt.Printf. If you write fmt.Printf("%q", 123) the program prints the character whose Unicode code point is 123, which is {. The new check warns when the value you pass to %q is an integer that is not a rune or a byte. This helps you spot accidental misuse of %q that might lead to confusing output.
Run it now
// This program demonstrates the behavior that go vet now warns about: using
// the %q verb with an integer that is not a rune or byte. The output shows
// that fmt.Printf("%q", 123) prints the character with code 123, which is
// '{'.
package main
import "fmt"
func main() {
// Print the result of formatting an integer with %q.
fmt.Printf("%q\n", 123)
}
What it printed when we ran it on Go 1.27.1
'{'
Run sends this program (for Solidity, the contract and its tests) to our own sandbox, where it is compiled and run once, with no network, and what it printed or the test report comes back here. Nothing is kept. Runs are counted per visitor for the day so everyone gets a turn; the details are on the legal page.
Written by gpt-oss-20b from the linked source · claims checked against the sources · archive, not individually reviewed