Swipe
SwipeSwipe
Swipe Apps

Paths

Motivation

Information

Variables & Basic Types · Lesson 8 of 9

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

🤖
Four types cover the vast majority of what you'll write in Go's early days. 🐹

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
Both score and count are int values — one declared explicitly with var, the other inferred with :=.

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
price and temperature both hold float64 values, Go's standard type for decimal numbers.
Quick check

Which is Go's default, recommended floating-point type for decimal numbers?

🤖
Notice the lowercase — coming from some other languages, this trips people up constantly. 👀

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
name is a string and isActive is a bool, holding the lowercase literal true.
Fill in the blank

Go's boolean type can only ever hold the value true or ____.

🤖
This is one of Go's quieter but genuinely useful design decisions. 🐹

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
None of these three variables were given an initial value, yet each one already holds a sensible default: 0, an empty string, and false.
True or 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 →