Concurrency Patterns in Go: context, sync, errgroup, Worker Pools and Goroutine Leaks
In Go, data accessed concurrently is either guarded by a mutex or handed to its owner over a channel; an unguarded map crashes the process, while an unguarded counter silently produces duplicate order IDs. Concurrent map writes and the race detector in Bookstore, fixing Service and memstore with mutexes, cancellation and deadlines with context, WaitGroup.Go, a 10,000-invoice worker pool with errgroup, Go 1.27's goroutineleak profile, and running a 15-minute test instantly with synctest.
15 Nov 2026
·
14 min
·
6