Módulo 16 · Concurrency Patterns — Lección 4 de 4 · ~12 min
Races, leaks & the -race detector
The three bugs interviewers ask about
Concurrency bugs are the ones that pass every test on your laptop and corrupt production at 3am. Three come up in every Go interview: data races, goroutine leaks, and deadlocks. You met leaks in the last lesson (a stuck send with no receiver — always give a goroutine a way out). This lesson is races and deadlocks, and the tool that catches them.
A data race is two goroutines touching the same memory at the same time with at least one write, and no synchronization. The result is undefined — a lost increment, a torn value, a crash. Worst of all it's nondeterministic: it might work a thousand times and fail the thousand-and-first.