Basic Types
Every labeled box in Go has a type.
A type says what kind of thing can sit in the box.
Go checks types when you build your program.
Basic types cover numbers, true/false, and text.
Whole numbers
int holds whole numbers like 3 or 28.
There are also int8, int16, int32, and int64 for smaller or bigger sizes.
uint and friends hold whole numbers that cannot be negative.
Decimal numbers
float32 and float64 hold numbers with a decimal point.
float64 is the usual pick for everyday math.
Bool true or false
bool is only true or false.
Go will not turn a number into true or false for you.
You must ask a yes/no question on purpose.
Strings, bytes, and runes
string holds text. You cannot change letters inside it in place.
byte is the same as uint8. It is one small number, often one byte of text.
rune is the same as int32. It is one character, like a letter or emoji.
Type conversions
Go will not change types by itself.
You convert with Type(value), like float64(i).
Think of it as pouring sand from one shaped cup into another.
Zero values by type
Every type has a starter value when the box is empty.
Numbers start at 0. Bool starts at false. String starts empty.
Next lesson looks at strings, Go's text type, in more detail.
Test yourself
Three quick questions made just for this lesson. Earn 10 XP per correct answer.