Working with Text
7 min · Go
Join strings, measure them, and format text with fmt.
Go · Working with Text0/5 cleared
Enemy 1 of 5
Strings and concatenation
A Go string is technically a read-only sequence of bytes, most often holding UTF-8 encoded text — but for everyday use, you can think of it the same way you think of strings in any other language: a piece of text in quotes.
Two strings are joined together with the same + operator used for adding numbers; Go determines from the operand types whether + means numeric addition or string concatenation. Because Go strings are immutable (they can't be changed in place), greeting + name always produces a brand-new string rather than modifying greeting itself.
You
Packet Wolf
Loading editor...
Ln 1, Col 1Spaces: 4
Sign up to fightTarget output: Hello, Ada