Go · Stage 1 – Storing Information · Lesson 10 of 64

Go’s Basic Types

Meet the four basic value types used in the earliest Go programs.

Go code

var count int = 3
fmt.Println(count)
Line-by-line explanation
  1. Count is declared as int.
  2. The whole number 3 is stored.
  3. Println displays it.
Expected output
3

No decimal point appears because this is a whole number.

Go code

var temperature float64 = 21.5
fmt.Println(temperature)
Line-by-line explanation
  1. Temperature is declared as float64.
  2. The decimal value is stored.
  3. Println displays it.
Expected output
21.5

The decimal part remains visible.

Go code

var message string = "Hello"
fmt.Println(message)
Line-by-line explanation
  1. Message is declared as string.
  2. Hello is stored as text.
  3. Println displays it.
Expected output
Hello

Quote marks mark the source-code string but are not printed.

Go code

var ready bool = true
fmt.Println(ready)
Line-by-line explanation
  1. Ready is declared as bool.
  2. Lowercase true is stored.
  3. Println displays it.
Expected output
true

Go boolean words are lowercase.