6. Manipulating Strings

C was created in America, back when it was fashionable to pretend that the rest of the world didn’t exist, so it used 7-bit ASCII1 characters to represent strings.

Go is more recent, and since then most technology companies in the USA have discovered that it’s quite a good idea to support other languages, mostly so you can sell things to people in other countries. Go uses UTF-8. This is entirely unsurprising, as UTF-8 was originally designed (on a diner placemat) by Rob Pike and Ken Thompson, two of the designers of Go.

Go strings are slightly higher-level than C strings, and there are some important differences. The most obvious is that the Go string type is immutable, like C constant strings and Java strings. Although ...

Get The Go Programming Language Phrasebook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.