A Go string is a read-only slice of bytes. The language
and the standard library treat strings specially - as
containers of text encoded in UTF-8.
In other languages, strings are made of “characters”.
In Go, the concept of a character is called a |
|
|
|
|
|
|
|
|
|
Since strings are equivalent to |
|
Indexing into a string produces the raw byte values at
each index. This loop generates the hex values of all
the bytes that constitute the code points in |
|
To count how many runes are in a string, we can use
the |
|
A |
|
We can achieve the same iteration by using the
|
|
This demonstrates passing a |
|
|
|
Values enclosed in single quotes are rune literals. We
can compare a |
|
|
|
|
Next example: Structs.