A Go string is a read-only row of bytes. One visible character can use 1 to 4 of them.
Think of a string as a strip of tape with numbered cells. Plain English letters take one cell each. A letter like “é” needs two cells and an emoji needs four, because Go stores text as UTF-8.
So len(s) counts cells (bytes), not characters. A rune is Go’s word for one character (a Unicode code point). []rune(s) and for i, r := range s walk the string character by character instead of byte by byte.
héllo🙂, then hello, then ééé. Compare the byte count and the rune count.s[1] not the character é?range loop: the index i jumps by 2 or 4 at multi-byte characters.len(s) as the number of characters. Use utf8.RuneCountInString(s) or len([]rune(s)).s[i] and expecting a character. You get one byte (a byte, i.e. uint8).s[0] = 'H' is a compile error). Strings are immutable; build a new one.