liveBook · Manning

Rune

A rune is Go’s predeclared alias for int32 that represents a Unicode code point.

How 4 Manning books explain it

100 Go Mistakes and How to Avoid Them

A rune is Go's representation of a Unicode code point, implemented as an alias of int32.

How it is used
Prevents byte-versus-code-point mistakes when counting, indexing, or iterating over Go strings.
How deep it goes
Defines rune and traces incorrect iteration through its output, then compares range values, rune slices, and UTF-8 rune counting.
Examples
Contrasts the three-byte `汉` with loops over `hêllo` that print a byte, a rune, or rune-slice positions.
What you can do after
Diagnose/debug with it: distinguish byte lengths and offsets from rune counts and positions, then select the appropriate iteration or conversion.

Read how 100 Go Mistakes and How to Avoid Them explains rune →

Go in Practice, Second Edition

A rune is Go's integer type for representing a Unicode code point.

How it is used
Uses runes to make string processing handle multibyte, non-ASCII characters correctly.
How deep it goes
Defines the Unicode-code-point type and demonstrates conversion to []rune, stopping short of deeper Unicode internals.
Examples
Demonstrates reversing an ASCII name and a name containing a non-ASCII character, then validating the fix with go test.
What you can do after
Diagnose and fix character-processing bugs by converting strings to rune slices before character-wise operations.

Read how Go in Practice, Second Edition explains rune →

Learn Go with Pocket-Sized Projects

A rune is Go's value type representing a single Unicode code point.

How it is used
Uses runes to represent individual Unicode code points and inspect multilingual strings.
How deep it goes
Defines rune literals and demonstrates iteration, then stops short of treating grapheme-like character units as native runes.
Examples
Uses '學', multilingual greetings, and the नमस्त string to contrast rune literals, strings, and combining marks.
What you can do after
Apply rune literals and []rune iteration, or choose Unicode normalization when code points do not match desired character units.

Read how Learn Go with Pocket-Sized Projects explains rune →

Go in Action, Second Edition

A rune is Go's alias for int32 that represents a Unicode code point independently of its encoded representation.

How it is used
Uses rune for Unicode-aware string iteration, character comparison, conversion, and inspection.
How deep it goes
Defines the int32 alias, demonstrates range and []rune conversion, and applies Unicode packages without detailing their full APIs.
Examples
Demonstrates 地鼠 iteration, []rune indexing, and À classification, case conversion, and encoded-length inspection.
What you can do after
Apply it via range loops and Unicode packages to process, classify, compare, and inspect characters.

Read how Go in Action, Second Edition explains rune →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.