Comment by naikrovek
1 day ago
I think maybe you've forgotten about the rune type. Rune does make assumptions.
[]Rune is for sequences of UTF characters. rune is an alias for int32. string, I think, is an alias for []byte.
1 day ago
I think maybe you've forgotten about the rune type. Rune does make assumptions.
[]Rune is for sequences of UTF characters. rune is an alias for int32. string, I think, is an alias for []byte.
`string` is not an alias for []byte.
Consider:
How many times does that loop over 6 bytes iterate? The answer is it iterates twice, with i=0 and i=3.
There's also quite a few standard APIs that behave weirdly if a string is not valid utf-8, which wouldn't be the case if it was just a bag of bytes.