An integer is converted to a string, which makes a character rather than its digits

tx0/go:string-of-intdefaultwarningbug

What it finds

string(n) with an integer n: a conversion from an integer to a string does not format the number but makes the character with that code point, so string(65) is "A" and string(-1) is "�". strconv.Itoa(n) gives the digits; string(rune(n)) says that a character was meant.

The operand must be a variable or parameter of this file declared with one of the integer types int, int8, int16, int64, uint, uint16, uint32, uint64 or uintptr, and string the predeclared type. byte and rune, which name characters, are left alone, and so are uint8 and int32, which are the same types.

From the rule's source, string_of_int.rs.

Example from the rule's tests
package p func f(n int, b byte, r rune, u uint64) []string {	var m int16 = 3	return []string{		string(n),tx0 reports: string(n) makes the character with code point n		string(b),		string(r),		string(u),tx0 reports: string(u) makes the character with code point u		string(m),tx0 reports: string(m) makes the character with code point m		string(rune(n)),	}}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:

tx0.toml
[rules]
"tx0/go:string-of-int" = "off"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/go:string-of-int] reason="..."

tx0 explain tx0/go:string-of-int shows the same in the terminal. Found a false positive? Report it.