ADocumentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
rune in Go is a built-in type alias for int32 that represents a single Unicode code point. It serves as the language’s standard mechanism for isolating and representing individual characters, distinguishing them from raw bytes or standard numeric integers.
Technical Specifications
- Underlying Type:
int32 - Memory Footprint: 4 bytes (32 bits)
- Zero Value:
0(which corresponds to the null character'\x00') - Encoding: Represents a specific Unicode code point, independent of its UTF-8 byte-length representation.
Syntax and Literals
Rune literals are expressed by enclosing one or more characters in single quotes (' '). Go supports multiple ways to define a rune literal, including raw characters, octal/hexadecimal escapes, and Unicode escapes.
Memory and Type Mechanics
Because Go strings are read-only slices of bytes (uint8), accessing a string via a standard index returns a single byte, not a complete character. A rune resolves this by allocating exactly 32 bits, which is sufficient to hold any valid Unicode code point (which requires up to 21 bits).
Iteration Behavior
When iterating over a string using afor...range loop, Go implicitly decodes the underlying UTF-8 byte sequence. Instead of yielding individual bytes, the loop yields rune values alongside their starting byte index.
Master Go with Deep Grasping Methodology!Learn More





