Grokking Concurrency in Go
Vote

0% completed

​

Testing with the Race Detector

A small counter type passed its tests 1,000 times in a row. The command go test -count=1000 ran both of its tests a thousand times each, and the whole run finished in 0.7 seconds with the word ok. The type had a data race the entire time.

One more run, this time with the -race flag, failed on the first attempt. The race detector printed the two lines of code involved, the goroutines that ran them, and the name of the failing test. Nothing about the code had changed between the two commands. Only the way the tests were built and observed had changed.

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content