Why are strings in Go immutable, and what is the relationship between a string and a []byte?

Last updated 20 June 2026

  • A string is an immutable pointer-plus-length over bytes, so it can be shared cheaply, used as a map key, and passed across goroutines without locking.

  • A []byte is the mutable counterpart, and conversions string(b) / []byte(s) copy the data. Indexing a string gives bytes, while range yields decoded runes.

  • For heavy concatenation use strings.Builder or a []byte to avoid repeated allocations.

  • https://www.reddit.com/r/rust/comments/1h15md8/goodbye_rust_i_wish_you_success_but_im_back_to_c/
  • https://www.reddit.com/r/golang/comments/1gfjnzm/since_when_is_senior_golang_developer_expected_to/
All Golang interview questions