The Go Race Detector has a goroutine limit of 8192 (at least on my system). One test I run is to see how my server code handles a large number of simultaneous open connections (right now I'm trying out > 15000). When I run go test --race
, therefore, that particular test fails. I'd rather it be skipped when run using -race
instead of failing directly. How can I do that?
The build tag race
is defined when building with the -race flag.
Move the tests you want to exclude to a file with the build constraint comment:
//go:build !race
If you are using Go 1.17 or earlier, then include an additional comment with the old build constraint syntax:
//go:build !race
// +build !race
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With