Well, the first question is what a string's internal representation should be, and they went with UTF8. Once you've decided on UTF8, the question is whether to hide the representation or expose it. If you decide to expose it, there's hardly any difference between an immutable byte array and string, so it's simpler in a way to have one type that can be used both ways.
I understood the article just fine. It's not wrong to say that in Go, text (called strings in other languages) is nearly always represented in UTF8 format and is commonly stored in variables of type string, or sometimes []byte.
Perhaps I should have left out the word "internal" since it's exposed.
Comments
Well, the first question is what a string's internal representation should be, and they went with UTF8. Once you've decided on UTF8, the question is whether to hide the representation or expose it. If you decide to expose it, there's hardly any difference between an immutable byte array and string, so it's simpler in a way to have one type that can be used both ways.
No, read the article more carefully. A Go string's internal representation is a sequence of bytes. There's nothing UTF-8 about it.
I understood the article just fine. It's not wrong to say that in Go, text (called strings in other languages) is nearly always represented in UTF8 format and is commonly stored in variables of type string, or sometimes []byte.
Perhaps I should have left out the word "internal" since it's exposed.
Yes, "internal representation" has a specific meaning. If you had said "standard representation" or something then I would have agreed with you.
Yes, there is: range on a string works on runes by decoding UTF-8.
That has nothing to do with "a string's internal representation". That is just how a range loop is defined/implemented.