You are previewing The Go Programming Language Phrasebook.

The Go Programming Language Phrasebook

Cover of The Go Programming Language Phrasebook by David Chisnall Published by Addison-Wesley Professional
O'Reilly logo

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 ...

The best content for your career. Discover unlimited learning on demand for around $1/day.