Go for Beginners
From your first program to slices, maps, structs, interfaces, errors, goroutines and a final project.
Tests check every exercise: in your browser and in the cloud
Exercises are compiled and checked on the site, so you need nothing installed to take the course. To run the lesson examples on your own computer, set it up in two steps.
Install Go
The lessons use Go 1.26 or newer.
- Download the installer for your system from go.dev/dl and run it.
- The installation guide shows how to check that Go is installed on Windows, macOS and Linux.
Install VS Code
Download VS Code and add the Go extension from the Go team.
Syllabus
- An error is a valueTheory
- errors.New and fmt.ErrorfTheory
- Quiz — creating an errorQuiz
- Checking if err != nilTheory
- Quiz — strconv.AtoiQuiz
- Wrapping with %w and errors.IsTheory
- Quiz — == or errors.IsQuiz
- Error types and errors.AsTheory
- Quiz — errors.As through %wQuiz
- Exercise: parse an ageExercise
- Exercise: division with an errorExercise
- Functions as valuesTheory
- Quiz — first-class functionsQuiz
- ClosuresTheory
- Quiz — a closure counterQuiz
- deferTheory
- Quiz — defer order and argumentsQuiz
- panic and recoverTheory
- Quiz — panic and recoverQuiz
- Exercise: filterExercise
- Exercise: accumulatorExercise
- ★ Exercise: repeat a functionExercise
- ★ Exercise: a panic becomes an errorExercise
- GoroutinesTheory
- sync.WaitGroupTheory
- Quiz — WaitGroupQuiz
- ChannelsTheory
- Quiz — a send with no receiverQuiz
- Buffers, close and rangeTheory
- Quiz — range over a closed channelQuiz
- selectTheory
- Mutex and data racesTheory
- Quiz — a counter under a MutexQuiz
- Exercise: sum in goroutinesExercise
- Exercise: a safe counterExercise
- Exercise: results as they are readyExercise