courses / go / level 3

level 3 · expert

advanced
go.

Write concurrent Go like a professional: goroutines, channels, context, tests, benchmarks and clean design.

  • 28 lessons
  • 7 units
  • 5 h 39 m in all
  • £0, for good

what’s inside.

For people who build things on their own and want code that others trust and can change.

Twenty-eight lessons take you from your first goroutine to worker pools, pipelines, cancellation and code that never races or leaks. You learn to test with tables, measure with benchmarks and shape your types with embedding and functional options. You finish by shipping a concurrent job runner that handles bad input and always prints the same sorted report.

every lesson goes the same way.

  1. meet it
  2. guess first
  3. your turn
  4. fix it
  5. nailed it

unit 1

Many things at once

Run work side by side, then wait for every piece to finish.

4 lessons · 47 min

  1. A goroutine runs alongside10 minStart work that runs at the same time as main, then wait for it to finish.
  2. Many goroutines, one wait12 minStart a goroutine for every item and collect the answers in a fixed order.
  3. The loop variable trap12 minSpot the Go 1.16 bug where every goroutine sees the same loop value.
  4. When one goroutine panics13 minStop one bad job from crashing every other job in the program.

unit 2

Channels

Pass values safely between goroutines, and know when they have all arrived.

4 lessons · 46 min

  1. A channel hands values over11 minPass a value from one goroutine to another, safely and in order.
  2. Buffered channels11 minGive a channel room for a few values so senders do not always wait.
  3. Closing and ranging12 minSay when no more values are coming, and loop until they have all arrived.
  4. Channel directions12 minWrite function types that say who may send and who may receive.

unit 3

Waiting on many things

Listen to several channels at once, never wait too long, and stop on a signal.

4 lessons · 47 min

  1. select waits on many12 minListen to several channels at once and handle whichever speaks first.
  2. Never wait11 minTry a send or receive, and do something else if it cannot happen now.
  3. Timeouts12 minGive slow work a time limit, and move on when it runs out.
  4. A done channel12 minTell every worker to stop at once with a single close.

unit 4

Sharing safely

Keep shared data correct when many goroutines touch it at once.

4 lessons · 49 min

  1. Data races13 minRecognise the bug that hides when two goroutines share one variable.
  2. Mutex12 minGuard shared data so only one goroutine at a time can change it.
  3. Atomic counters11 minCount safely from many goroutines without a lock.
  4. Share by communicating13 minGive data a single owner goroutine and talk to it over channels.

unit 5

Concurrency patterns

Use the proven shapes: worker pools, pipelines, fan-out and fan-in.

4 lessons · 49 min

  1. Worker pools12 minShare a long queue of jobs between a fixed number of goroutines.
  2. Pipelines12 minChain small stages together with channels, like a factory line.
  3. Fan out, fan in13 minSpread work across many goroutines, then gather every result into one channel.
  4. Errors from workers12 minBring every error home from your goroutines and report it in a fixed order.

unit 6

Stopping on time

Cancel work, set deadlines and make sure every goroutine finishes.

4 lessons · 50 min

  1. Context and cancelling12 minHand a stop signal to your goroutines and use it to end their work.
  2. Deadlines and timeouts12 minGive a whole job a time limit that every part of it can see.
  3. Stop without leaking13 minMake sure every goroutine you start has a way to finish.
  4. Context in a web handler13 minStop slow work when the visitor has already gone.

unit 7

Code like a professional

Test, measure and shape your code the way experienced Go developers do.

4 lessons · 51 min

  1. Table-driven tests12 minTest many cases with one loop and clear failure messages.
  2. Benchmarks and profiling14 minMeasure how fast your code is and how much memory it asks for.
  3. Embedding12 minBuild a type out of smaller types and reuse their methods.
  4. Functional options13 minBuild things with sensible defaults and settings that read like English.
end of level 3 level check: a concurrent job runner Build one small project with everything from this level. Pass it and your face levels up. see the check

finished go?

pick your next language.

see all courses