Skip to main content
InterviewHubPRO
Section Overview
Q11

Question 11 of 50

Part 1: Go Language Core, Memory & Runtime Internals (1 - 15)

22%
Golang & Concurrency (50 Qs)•Part 1: Go Language Core, Memory & Runtime Internals (1 - 15)

Strings, Runes, and Bytes: UTF-8 Representation and Zero-Copy Conversions.

senior LevelSvelte 5

In Simple Words:

  • A string is an immutable 16-byte slice header pointing to read-only UTF-8 bytes (pointer, len).
  • byte is an alias for uint8.
  • rune is an alias for int32 representing a Unicode Code Point.
  • Iterating with for i := 0; i < len(s); i++ accesses raw bytes; iterating with for _, r := range s decodes Unicode runes.
  • In Go 1.20+, use unsafe.String and unsafe.SliceData for zero-allocation conversions between []byte and string.