Curriculum Foundations Strings, bytes, runes
Strings, bytes, runes
Go strings are immutable byte sequences. There are no template literals — fmt.Sprintf does the job. A byte is an alias for uint8; a rune is int32 and represents a Unicode codepoint. When you range over a string, you get runes (codepoints), not bytes. This matters more than it sounds.
Exercises
10 ready
01
pick one
TypeScript has one string type and no character type — 'A' and
02
pick one
TypeScript template literals interpolate values directly into a
03
pick one
Iterating over a string in TypeScript with for...of gives you
04
pick one
TypeScript strings carry their methods (String.prototype.toUpperCase,
05
fill blanks
TypeScript calls string methods on the string itself
06
fill blanks
TypeScript's split cuts a string into pieces, called as a method
07
type one line
TypeScript's startsWith is a method; Go's equivalent is a function
08
type one line
TypeScript joins arrays with array.join(separator). Go's
09
write a program
TypeScript template literals have no direct Go analogue — fmt.Sprintf
10
write a program
Write a program that iterates over the string "héllo" using