How to Iterate Over Characters in a Go String

Iterate over Go string characters using a range loop to get correct Unicode rune handling.

Use a range loop over the string to iterate over its runes (Unicode characters), which handles multi-byte characters correctly.

s := "Hello, δΈ–η•Œ"
for i, r := range s {
	fmt.Printf("Index: %d, Rune: %c\n", i, r)
}

If you specifically need bytes (not recommended for non-ASCII), range over a []byte slice instead.