Reference:
https://golang.org/doc/articles/race_detector.html
Usage:
$ go test -race mypkg // to test the package
The options are:
https://golang.org/doc/articles/race_detector.html
Usage:
$ go test -race mypkg // to test the package
$ go run -race mysrc.go // to run the source file
$ go build -race mycmd // to build the command
$ go install -race mypkg // to install the package
Options:
The GORACE environment variable sets race detector options.
The format is:
$ GORACE="option1=val1 option2=val2"
The options are:
- log_path (default stderr):
The race detector writes its report to a file named log_path.pid. The special names stdout and stderr cause reports to be written to standard output and standard error, respectively. - exitcode (default 66):
The exit status to use when exiting after a detected race. - strip_path_prefix (default ""):
Strip this prefix from all reported file paths, to make reports more concise. - history_size (default 1):
The per-goroutine memory access history is 32K * 2**history_size elements.
Increasing this value can avoid a "failed to restore the stack" error in reports, at the cost of increased memory usage. - halt_on_error (default 0):
Controls whether the program exits after reporting first data race.
e.g
$ GORACE="log_path=/tmp/race/report strip_path_prefix=/my/go/sources/" go test -race
Excluding Tests with build tag:
// +build !race package foo // The test contains a data race. See issue 123. func TestFoo(t *testing.T) { // ... } // The test fails under the race detector due to timeouts. func TestBar(t *testing.T) { // ... } // The test takes too long under the race detector. func TestBaz(t *testing.T) { // ... }
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.