Concurrency primitives of Golang: how to use and how not to
summary
Compares concrete code patterns using channels, waitGroups, atomic ops and mutexes and shows a broken example that deadlocks when wg.Add() is invoked inside a goroutine plus the corrected version that avoids the race, not theory. Demonstrates a broadcast pattern for multiple listeners (channel vs condition alternatives) and an atomic counter to let N workers signal completion, with microbench snippets and a working refactor that eliminates the race and simplifies coordination.
AI-written summary · about
