A rune is Go's value type for one Unicode code point. Write rune literals with single quotes, such as '學'; use double quotes for strings and backticks for raw strings. section 2.3.2
Converting a string to []rune lets Go iterate through its Unicode code points, but a rune does not necessarily represent a user-perceived character. section 5.4
Keep these distinctions in mind:
- Use single quotes for one rune, double quotes for ordinary string literals, and backticks for raw string literals. section 2.3.2
- Treat combining marks carefully: []rune("नमस्त") produces separate code points rather than combining related symbols into one unit. section 5.4
- Use golang.org/x/text/unicode/norm when Unicode normalization and character combination exceed native rune handling. section 5.4
Inspecting runes
The loop `for _, r := range []rune(s)` converts a string to runes and prints each code point separately, making combining marks visible. section 5.4
Listing 5.40 Understanding the नमस्ते case
func main() {
s := "नमस्त"
for _, r := range []rune(s) {
fmt.Print(string(r) + " ")
}
}
Inspect the runnable Devanagari example that prints each rune in a string. section 5.4



