z-go-concurrency

Installation
SKILL.md

Go Concurrency

Every goroutine is a liability until proven necessary. Correctness and leak-freedom first.

Principles

  1. Give every goroutine an exit condition and an owner that waits for completion. A WaitGroup joins work; it does not cancel or unblock it.
  2. Channel sends copy values, not referenced data. Choose exclusive ownership transfer, immutable sharing, or synchronized mutation.
  3. Pointer payloads are valid under that protocol. Copied slices, maps, and pointer-bearing structs still share storage; the sender must stop accessing transferred mutable data until ownership returns.
  4. Assign one closer. Close only after all possible sends finish; with multiple senders, join them before closing. sync.Once prevents duplicate closes, not send/close races.
  5. Specify channel direction (chan<-, <-chan) — compiler prevents misuse.
  6. Default to unbuffered channels; buffers mask backpressure.
  7. Guard channel operations that must unblock on cancellation with ctx.Done(). A ready cancellation case has no priority over other ready cases.
  8. Reuse timers when repeated time.After allocations matter; check effective timer semantics before choosing a reset/drain protocol.

Channel state and visibility

Installs
15
First Seen
Jul 2, 2026