Integers

int and uint are the most efficient size for integers on a given platform. They have the same size, either 32 or 64 bits. Different compilers can make different choices on whether so use one or the other.

rune is a synonym for int32 and indicates that a value is a Unicode code point. Runes are printed with verbs %c or %q:

a := ‘a’
fmt.Printf(“%d %[1]c %[1]q\n”, a) // “97 a ‘a'”

byte is a synonym for uint8. It usually contains a piece of raw data.

uintptr is an unsigned integer type used to represent pointer values. It’s size is not specified. It is generally used for low-level programming (i.e. when interoperating with C).

int, int32, uint, uintptr, and so forth, are different types and require explicit type conversion when used in a same operation:

Testing whether a specific result is equal to math.NaN (not a number) is dangerous because comparisons with NaN always yields false.

Complex Numbers

Go provides two sizes of complex numbers, complex64 and complex128. The built-in function complex creates a complex number from its real and imaginary components. The built-in real and imag functions return the real and imaginary components, respectively:

Floating-point literals or decimal integer literals immediately followed by i, as in 3.14i or 1i, denote a complex number with a zero real component.

The math/cmplx package provides functions for working with complex numbers.

Booleans

Two possible values: true and false. The zero value for boolean types is false.

Strings

In Go strings are immutable sequences of bytes. By convention, text strings are interpreted as UTF-8 encoded sequences of Unicode code points (runes). Want to know more about Unicode/UTF-8, I recommend this excelent blog post from Joel Spolsky.

A string literal is a sequence of bytes inside double quotes, such as "hello world". The zero value for string types is the empty string "".

Raw string literals are represented like `hello world`. In a raw string literal, no escape sequences are processed. Raw string literals are a generally used to write regular expressions, HTML, JSON or YAML.

The built-in len function returns the number of bytes (not runes) in a string, and the index operation myString[i] retrieves the i-th byte of myString.

The i-th byte of a string is not necessarily the i-th character of a string, because the UTF-8 encoding of a Unicode code point can require two or more bytes.

The unicode package provides functions for working with runes, and the unicode/utf8 package provides functions for encoding and decoding runes as bytes using UTF-8.

It is possible to specify characters in a string using Unicode escapes followed by their numeric code points (his a hexadecimal digit):