Basic Types
A free lesson from Swipe Coding · Go, level 2 · updated October 2026
By the Swipe team, founded by Colin · how we make lessons
Go has several built-in basic types, but four of them cover most of what you'll use day to day: int for whole numbers, float64 for decimal numbers, string for text, and bool for true/false values. int's exact size depends on the platform, but you can treat it as "a whole number" for now — Go also offers more specific sized types like int32 and int64 for when you need precise control.
var score int = 100 count := 42
float64 is Go's default, recommended floating-point type for decimal numbers — there is also a float32 for when memory is tight, but float64 is what you should reach for unless you have a specific reason not to.
var price float64 = 19.99 temperature := 98.6
Which is Go's default, recommended floating-point type for decimal numbers?
string holds text, written between double quotes, and bool holds exactly one of two values: true or false, always written lowercase in Go — unlike languages that capitalize their boolean literals.
name := "Maya" isActive := true
Go's boolean type can only ever hold the value true or ____.
Go automatically gives every variable declared with var but no initial value a predictable "zero value" instead of leaving it undefined: 0 for numeric types like int and float64, an empty string "" for string, and false for bool. This guarantees a variable is always in a valid, known state from the very moment it is declared.
var count int var name string var active bool fmt.Println(count, name, active) // 0 false
In Go, a variable declared with var but given no initial value automatically gets a predictable zero value instead of being left undefined.
Keep your streak going in Swipe Coding
Swipe through every level of Go on your iPhone — with XP, stars, streaks, a personal advisor and the full track beyond these free levels.
Get the Swipe apps →