Foundations
Your first steps with Go: syntax, types, and control flow.
- 01Hello, Gopher
Every Go program starts with package main and func main.
- 02Variables & Types
Declare, infer, and format Go's basic types.
- 03If, Else, Switch
Branching in Go — parentheses-free, braces-required.
- 04For Loops & range
Go has one loop keyword — `for` — and `range` to iterate.
- 05Functions & Multiple Returns
Functions can return more than one value.
- 06Constants & iota
Compile-time values and Go's auto-incrementing identifier.
- Face the bossBossBoss trialBoss: The FizzBuzz Gauntlet
Structuring Data
Slices, maps, structs, embedding, and pointers.
- 01Arrays & Slices
Slices are Go's growable view over an array.
- 02Maps
Key/value stores with the comma-ok lookup.
- 03Structs & Methods
Composite types with attached methods and receivers.
- 04Embedding & Composition
Go composes types by embedding, not by inheritance.
- 05Pointers
Share and mutate with & and *.
- 06Defer
Defer runs at function exit, in LIFO order.
- 07Strings & Runes
Go strings are UTF-8 bytes; iterate with runes for characters.
- Boss trialBoss: Inventory Ledger
Interfaces & Errors
Polymorphism the Go way — plus idiomatic error handling.
- 01Interfaces
Structural typing: implement the methods, satisfy the interface.
- 02Errors
Errors are values you return, check, wrap, and inspect.
- 03Type Assertions & Type Switch
Extract a concrete type — and avoid the typed-nil trap.
- 04Generics
Type parameters, added in Go 1.18.
- 05Panic & Recover
Unrecoverable errors, and the escape hatch that stops them.
- Boss trialBoss: Shape Kingdom
Concurrency
Goroutines, channels, select — the Go superpower.
- 01Goroutines
Prefix a call with `go` to run it concurrently.
- 02Channels
Typed pipes that carry values between goroutines.
- 03Select
Wait on several channel operations at once.
- 04WaitGroup & Mutex
Wait for goroutines to finish; guard shared state.
- 05sync.Once
Guarantee one-time initialization across goroutines.
- Boss trialBoss: The Worker Pool
Real-World Go
Modules, HTTP, JSON, context, and testing.
- 01JSON
Encode and decode with struct tags.
- 02HTTP Handlers
net/http gives you a real server in a handful of lines.
- 03Modules
Every project is a module tracked by go.mod.
- 04Context
Cancel, time out, and carry request-scoped values.
- 05Testing with go test
Files ending in _test.go and functions named TestXxx — exactly the harness you have been using.
- Boss trialBoss: Ship It