A string is converted to runes only to range over them, which ranging over the string does

tx0/go:range-over-rune-conversionrecommendedwarningperformance/allocationdepth fastperformance

What it finds

for _, r := range []rune(s): ranging over a string already decodes it rune by rune, so the conversion only allocates a slice of every rune first. for _, r := range s gives the same runes.

Reported is a range over a conversion []rune(...) whose index is _ or absent, since with an index the two loops count differently: runes against bytes.

From the rule's source, range_over_rune_conversion.rs.

Example from the rule's tests
package p func count(s string) (n int) {	for _, r := range []rune(s) {tx0 reports: ranging over the string gives the same runes without the slice		if r == 'a' {			n++		}	}	for i, r := range []rune(s) {		n += i + int(r)	}	return 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 from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/go:range-over-rune-conversion" = "warning"

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:range-over-rune-conversion] reason="..."

tx0 explain tx0/go:range-over-rune-conversion shows the same in the terminal. Found a false positive? Report it.