A rune is Go’s integer type for representing a Unicode code point. Use a slice of runes when processing characters whose UTF-8 representation may occupy multiple bytes; indexing the original string as bytes can corrupt operations such as reversal. section 1.2.4
Reverse a name safely
A byte-based reversal can produce invalid output for a non-ASCII name. Convert the string to []rune, iterate over the rune slice backward, append each rune, and convert the result back to a string. Running go test then verifies the corrected behavior. section 1.2.4
func reverseNameFixed(name string) string {
reversed := make([]rune, 0)
runes := []rune(name)
for i := len(runes) - 1; i >= 0; i-- {
reversed = append(reversed, runes[i])
}
return string(reversed)
}
Shows the complete rune-slice implementation for reversing a string. section 1.2.4



