knaxuslearn · build · ship

Roadmaps / Go / Phase 1

Phase 1 of 4 · Study weeks 1-4

The language, goroutines and bounded concurrency

This phase makes the first checkpoint possible: a delivery core that never runs away, stops when told and shows when it leaks.

Topics every week

  1. Week 18 h
    • Types, interfaces and generics
    • Errors, wrapping and errors.Is
    • Slices, maps and aliasing
    • The memory model

    Hand inA catalogue of 10 traps (nil interfaces, slice aliasing, loop variables), tested

  2. Week 28 h
    • Goroutines and channels
    • context and cancellation
    • errgroup
    • Channels against mutexes
    • Goroutine lifetimes

    Hand inA worker pool with cancellation and a test that proves no worker outlives it

  3. Week 38 h
    • The scheduler and what blocks it
    • The garbage collector and GC settings
    • Escape analysis
    • pprof for CPU, heap and goroutines

    Hand inA profile report: one hot function and one allocation source, with a fix

  4. Week 48 h
    • The race detector
    • Fuzzing and table tests
    • testing/synctest for time
    • The goroutine leak profile

    Hand inCheckpoint 1: the delivery core, its tests and the reference table

Practice projects

  • Practice 1, the trap catalogue (Week 1): write 10 cases that surprise people (a nil pointer in a non-nil interface, a slice that shares memory after append, a map iteration order). Done when: each has a test that asserts the surprising result and a one-line rule.
  • Practice 2, the leak (Week 2): start a goroutine that blocks on a channel nobody reads. Done when: a test fails because of the leak, and the fix uses a context so the goroutine exits when the caller stops.
  • Practice 3, the pool (Week 4): build a pool with a global limit, a per-key limit and cancellation. Done when: 100,000 queued tasks never run more than the limits, memory stays flat and a cancelled task never starts.
  • Optional, a pipeline: chain three stages with channels. Done when: closing the first stage lets the others drain and exit, and the race detector stays quiet.

GitHub repos to study

Existence and last commit were checked on 22 Nov 2026 by shallow clone. Every repository below had a commit in the last 12 months. Look at the README for archive notices before you rely on one.

RepoWhat to readWeek
golang/goruntime scheduler and sync package sources3
uber-go/guideA style guide: goroutine lifetimes, errors and channel size2
google/pprofThe profile format and the visualisations3
golang/toolsThe analysis passes behind go vet4

Milestone checkpoint

Build Checkpoint 1. Write the test harness first: a fake server with hung, slow and fast endpoints, and a counter of the highest number of deliveries in flight to each. Then add the pool, the limits and the cancellation. Add the seeded leak and watch the leak profile catch it. Hand in the reference table with your own numbers, ADR-1 (errors and cancellation) and ADR-2 (pool and limits).

Check yourself

Answer each question in your head first, then open it to check.

  1. Why can an interface holding a nil pointer be non-nil?
    An interface value holds a type and a value. A nil pointer of a concrete type has a type, so the interface is not nil.
  2. What does context cancellation stop, and what does it leave running?
    It signals code that listens for it, such as http requests and select on ctx.Done(). Code that never checks the context keeps running.
  3. When do you use a channel and when a mutex?
    A channel to pass ownership or signal events; a mutex to protect shared state. A mutex is simpler when many goroutines touch one value.
  4. What does the race detector find, and what does it miss?
    It finds data races that happen in the run. It misses races that never occur in your tests, and it does not find deadlocks or leaks.
  5. Why does go func() per event fail under load?
    Nothing bounds the goroutines, so slow endpoints pile up goroutines and memory until the process dies.