Go Practice
Master goroutines, channels, interfaces, and simplicity-driven design.
Language Essentials
Section titled “Language Essentials”| Concept | Details |
|---|---|
| Memory Model | GC, stack-allocated by default, escape analysis, pointers but no arithmetic |
| Type System | Static, structural typing, interfaces (implicit), generics (1.18+) |
| Error Handling | error interface, multiple returns, errors.Is/As, no exceptions |
| Concurrency | Goroutines, channels, select, sync package, context cancellation |
| Build | go build, modules (go.mod), go test, go vet |
| Standard | Go 1.22+ |
Key Idioms
Section titled “Key Idioms”- Accept interfaces, return structs
if err != nil— explicit error checking- Table-driven tests with
testingpackage context.Contextthreaded through call chains- Channel direction in function signatures (
chan<-,<-chan) - Embedding for composition over inheritance
deferfor cleanup, runs LIFO
Reference Documentation
Section titled “Reference Documentation”- A Tour of Go — free, interactive
- Effective Go — free, essential reading
- Go standard library — API docs
- Go Blog — official articles
- The Go Programming Language (Donovan & Kernighan) — comprehensive
Practising these
Section titled “Practising these”practice/bin/ol list build go # which of these have references yetpractice/bin/ol start build go 01 # clone it stubbed into .scratchpad/practice/bin/ol check build go 01 # run it; exit code is the verdictpractice/bin/ol diff build go 01 # your attempt against the referenceExercises are ordered by concept, not by difficulty, so pick by the stars rather than by the number. An exercise listed below with no reference yet is a row in this table and nothing more; see the practice path for how the harness works.
Exercises
Section titled “Exercises”| # | Exercise | Concepts | Difficulty |
|---|---|---|---|
| 01 | Concurrent web crawler | Goroutines, channels, sync.WaitGroup, rate limiting; course version: ag.06 | ⭐⭐⭐ |
| 02 | In-memory key-value store | sync.RWMutex, interfaces, HTTP handler; course version: gw.06 | ⭐⭐ |
| 03 | Worker pool | Bounded concurrency, context cancellation; course version: dur.04 | ⭐⭐⭐ |
| 04 | Generic sorted set | Generics, type constraints, cmp.Ordered; course version: dur.07 | ⭐⭐⭐ |
| 05 | Log-structured storage | io.Reader/Writer, binary encoding, file I/O; course version: dur.01 | ⭐⭐⭐⭐ |
| 06 | Pub/sub message broker | Channels, fan-out, select, graceful shutdown; course version: dur.03 | ⭐⭐⭐ |
| 07 | Rate limiter (token bucket) | time.Ticker, atomic operations, middleware; course version: gw.03 | ⭐⭐ |
| 08 | Raft consensus (simplified) | State machines, RPC, leader election; course version: dur.10 | ⭐⭐⭐⭐⭐ |
| 09 | Dependency injection container | Reflection, interfaces, sync.Once | ⭐⭐⭐ |
| 10 | gRPC service + client | Protocol buffers, streaming, interceptors; course version: dur.04 | ⭐⭐⭐⭐ |