Go Koans
Go is a small, statically typed, compiled language, built for simple and reliable software: fast builds, a garbage collector, and concurrency with goroutines and channels in the language itself. It runs much of the cloud, from Docker and Kubernetes to countless web services and command-line tools. These koans cover its types and zero values, strings and runes, slices and maps, structs, methods and interfaces, errors, generics and iterators, goroutines and channels, and testing itself.
73 koans in 17 groups, tested with testify. Each is a small program whose tests fail: replace every ___ until they pass.
Awakening
Tests that fail until you fill them in, and Go's first ideas: variables, constants and types.
Numbers
Integer and floating-point arithmetic, sized integers, and converting numbers to text and back.
Strings
Strings as bytes, the strings package, runes and UTF-8, and formatting with fmt.
Control flow
if, for (Go's one loop), switch, and labels.
Functions
Several results, variadic functions, closures and recursion.
Arrays and slices
Fixed-size arrays, and slices: views of arrays that grow with append.
Maps
Maps from keys to values, sets, and maps shared by reference.
Structs
Grouping fields into structs, pointers, copies, and embedding.
Methods and interfaces
Methods on any type, value and pointer receivers, and interfaces that types satisfy without saying so.
Errors
Errors as values: returning them, wrapping them, and finding them in a chain.
Defer, panic and recover
Calls deferred to the end of a function, and stopping a panic.
Generics
Functions and types with type parameters, and the constraints that limit them.
Iterators
Ranging over functions, the iter package's sequences, and building on them.
Goroutines and channels
Running functions concurrently, and passing values between them.
The standard library
Sorting, time, JSON, regular expressions and reading text, from Go's own packages.
Testing
Table-driven tests, subtests, assertions and helpers: how Go code is tested.
Puzzles
Small programs to read and predict: loop variables, shadowing, shared slices, defers and method sets.