The type rune
in Go is defined as
an alias for
int32
and is equivalent toint32
in all ways. It is used, by conv
The fact that it's allowed a negative value lets you define your own rune
sentinel values.
For example:
const EOF rune = -1
func (l *lexer) next() (r rune) {
if l.pos >= len(l.input) {
l.width = 0
return EOF
}
r, l.width = utf8.DecodeRuneInString(l.input[l.pos:])
l.pos += l.width
return r
}
Seen here in a talk by Rob Pike: Lexical Scanning in Go.