Junior — Middle
What abstraction mechanism in Go language is intended for representing characters or tokens?
sobes.tech AI
Answer from AI
In the Go language, the rune type is used to represent characters or tokens. It is an alias for the int32 type, designed to store Unicode code points. Thus, rune allows working with Unicode characters, not just bytes.
Example of usage:
var ch rune = '世' // Unicode character
fmt.Printf("%c %U\n", ch, ch) // output: 世 U+4E16
This makes it convenient to process text in different languages, taking into account multilingual characters.