← Course map

GO LEARNING PATH · 13 LESSONS

Concurrency

Goroutines, channel ownership, select, buffers and who may send.

  1. An unbuffered channel is a meeting

    Say what blocks, and for how long, on a channel with no buffer.

    3 min · Prediction challenge

  2. go returns nothing

    Get a result out of a goroutine, and know when the program stops waiting.

    3 min · Prediction challenge

  3. Cancellation is a request; joining proves exit

    Design a worker so it can stop waiting and its owner can wait for it to finish.

    3 min · Worked lesson

  4. The sender closes, the receiver ranges

    Decide who closes a channel, and why the other side must not.

    3 min · Worked lesson

  5. select waits on several things; context says stop

    Make a blocking operation cancellable without a flag or a kill switch.

    3 min · Worked lesson

  6. A mutex is for state; a channel is for handing over

    Choose between a mutex and a channel for a given problem.

    3 min · Worked lesson

  7. The worker pool, written once

    Build a fixed set of workers that finishes cleanly.

    3 min · Worked lesson

  8. More goroutines are not more capacity

    Bound active workers and queued work according to the resource that actually limits throughput.

    3 min · Worked lesson

  9. A buffer is a mailbox, not a meeting

    Send n values on a channel of capacity n without another goroutine.

    3 min · Worked lesson

  10. range over a channel ends when it closes

    Drain a channel with range, and close it from the sender.

    3 min · Worked lesson

  11. default makes select try, not wait

    Receive from a channel if a value is ready, and return if it is not.

    3 min · Worked lesson

  12. The arrow in the type is who may send

    Write a producer that takes chan<- int and closes it.

    3 min · Worked lesson

  13. sync.Once runs a function one time, for everyone

    Initialise shared state without a lock you have to remember.

    3 min · Worked lesson