Strings, bytes, runes and characters in Go
Official explanation of string immutability, bytes versus runes, UTF-8, and text-processing pitfalls.
Official explanation of string immutability, bytes versus runes, UTF-8, and text-processing pitfalls.
- Author: Rob Pike
- Authority: primary
- Kind: blog
- URL: https://go.dev/blog/strings
What it covers
- string immutability
- bytes vs runes
- UTF-8 and indexing behavior
Why authoritative
Canonical Go blog post on string and UTF-8 semantics.
Use when
- how do strings work in Go
- should this Go code use bytes or runes
- is this string slicing logic UTF-8 safe in Go
Keywords
- strings, bytes, runes, UTF-8, text