Go concurrency, one channel at a time
A practical mental model for channels, cancellation and avoiding the usual deadlocks.
Channels are easy to start with and easy to misuse. The trick is to decide ownership up front: who creates a channel, who writes to it, and who is responsible for closing it.
Context cancellation should be the default escape hatch for any goroutine that can block. If a worker cannot observe cancellation, it will outlive the request that started it.
When in doubt, keep the concurrency at the boundary and keep the core logic sequential. It is easier to reason about and usually fast enough.