We explain what
data race means in Go: why concurrent code can “sometimes work” while still being incorrect, how races arise with
counter
++, why
WaitGroup does not make data safe, why concurrent
append calls into a shared slice and writes to a
map are dangerous, and how to avoid races without
Mutex,
atomic, or channels — by separating ownership and reading results only after
wg
.
Wait
().