October 2015
Beginner to intermediate
400 pages
14h 44m
English
Even with the greatest of care, it’s all too easy to make concurrency mistakes. Fortunately, the Go runtime and toolchain are equipped with a sophisticated and easy-to-use dynamic analysis tool, the race detector.
Just add the -race flag to your go build, go run,
or go test command.
This causes the compiler to build a modified version of your
application or test with additional instrumentation
that effectively records all accesses to shared variables
that occurred during execution, along with the identity of the
goroutine that read or wrote the variable.
In addition, the modified program records all synchronization events,
such as go statements, channel operations, and calls to
(*sync.Mutex).Lock, (*sync.WaitGroup).Wait ...