Proposals Unofficial Go proposal tracker

Restrict integer-to-string conversions to byte and rune

#3939 · spec · medium impact · Implemented in Go 1.28 ·

Go lets you convert any integer to a string, producing the UTF-8 encoding of that code point. This is a historical leftover. It confuses readers, who often expect string(65) to produce "65" rather than "A". Invalid code points such as 0xD800 silently become "\uFFFD". go vet has flagged these conversions for years.

Starting with language version 1.28, a conversion from an integer to a string will be allowed only if the integer has type byte or rune, or is an untyped rune constant. Converting other integer types, such as int, int64 or uint32, becomes a compile error. Byte and rune slice conversions are unchanged.

var i int = 65
s := string(i)        // error in Go 1.28
s = string(rune(i))   // OK: "A"
s = strconv.Itoa(i)   // OK: "65"
s = string('A')       // OK: untyped rune constant
Proposal
#3939 by robpike
Status
Implemented on Nov 11, 2026
Release
Go 1.28
Impact
medium
Area
spec