Loading…
0+ curated questions with the same answer shape every time: quick recap, deep dive, pitfalls, and follow-ups. Coverage includes .
The sync package provides low-level synchronisation primitives for when channels are the wrong tool. This module covers sync.Mutex and sync.RWMutex (the classic producer/consumer and read-heavy cache patterns, the 'copy lock' pitfall), sync.WaitGroup for waiting on a group of goroutines to finish (Add before goroutine, Done in goroutine, Wait in caller — the off-by-one error that causes panics), sync.Once for lazy singleton initialisation (thread-safe exactly-once execution, why it's preferred over init()), sync.Pool for reducing GC pressure in high-throughput code (the HTTP handler that pools byte.Buffer allocations), sync.Map for concurrent maps without external locking (trade-offs vs map + Mutex), and the sync/atomic package for lock-free integer operations. The interview litmus test is 'when would you use a Mutex instead of a channel?' — this module answers that question precisely.
Full catalog
Topics are ordered for learning. Within each topic, rows are numbered 1–0 globally so you always know where you are. Collapse topics if you want a lighter view — use Expand all when you need the full list again.
Numbers 1–0 follow the order we recommend — click any row to open the full answer, or use the sticky Next link at the bottom of each page to go Q1 → Q0.