The Range Over String Returns Runes, Not Bytes

Go range loops over strings return runes (Unicode characters) by default; convert to []byte to iterate over raw bytes.

In Go, a range loop over a string yields Unicode code points (runes), not raw bytes, because strings are UTF-8 encoded sequences of characters. To iterate over the raw bytes instead, you must range over a []byte slice created from the string.

s := "hello"
// Iterates over runes (characters)
for _, r := range s {
    // r is a rune (int32)
}

// Iterates over bytes
for _, b := range []byte(s) {
    // b is a byte (uint8)
}