race detector

A checking mode, turned on with -race, that makes a Go program report when two goroutines touch the same memory unsafely.

In more detail

It watches memory accesses while tests or programs run and prints both conflicting stack traces when it finds a data race. It only finds races that actually happen during that run, so exercise concurrent paths in tests. It slows the program down, so use it in testing rather than production.

Example

go test -race ./...

Related terms

Taught in

References