Golang & Concurrency (50 Qs)•Part 2: Concurrency, Channels & The GMP Scheduler (16 - 32)
How does the Go Race Detector work (`go test -race`)?
senior LevelGolang
In Simple Words: Built on Google's ThreadSanitizer (TSan):
- Compiles the binary with instrumentation tracking every memory access and synchronization event.
- Detects unsynchronized concurrent read-write access to the same memory location.
- Overhead: ~2–10x CPU and 5–20x memory overhead. Always run in CI pipelines!