In the go language, the bottom string is stored in a byte array and cannot be changed.
For example, the s:="Go编程" fmt.Println(len(s)) output should be 8 because the Chinese characters are stored in 3 bytes.
len(string(rune('编')))The result is 3.
If we want to get what we want, we need to convert to rune slices and then use the built-in Len function as fmt.Println(len([]rune(s))) a result of 4.
So if you use string to store Unicode, if you have Chinese, the subscript is inaccessible because you can only get a byte. If you want to access Chinese, you still need to use Rune to slice it, so you can access it by following the table.
Rune is the alias of Int32 in Golang and is used to differentiate between character values and integer values. Using the above example, Rune can be understood as a value that can represent a Unicode encoded value of int, called a code point. But the Go Language abstracts this code point into rune.