Mahdi.Kh
September 21, 2026
We get familiar with the string data type in Go and learn how to work with string variables.
The string type is used to store text. In Go, text is stored per the Unicode standard, encoded as UTF-8.
Unicode is a global standard for representing, storing, and exchanging text characters. This standard aims to cover every character in every living and dead language in the world, along with symbols and marks.
Unicode assigns each character a unique code (a code point). For example, the letter A has the unique code U+0041, and the character ش in Persian has the unique code U+0634. Unicode is just a logical map from characters to unique codes, and it doesn't specify how these codes are physically stored.
UTF-8 (short for "8-bit Unicode Transformation Format") is an encoding for storing and transmitting Unicode characters. That is, it's a method that turns Unicode's unique codes into physical bytes. UTF-8 uses 1 to 4 bytes to represent each unique code.
Sometimes you need to join several pieces of text together; to do this, you can use the + operator:
Non-text data can't be joined using +; one way to join non-text data is to use the fmt package:
Strings are an important part of any programming language, and Go has many tools for working with them, which we'll cover in more detail in later parts.
Previous part: The Boolean Data Type | Golang basics
Next part: The slice Data Type | Golang basics