Disable race detection in test binary

1k views Asked by At

Is there a way to disable the data race checking in a compiled test binary?

Sometimes I want to specifically exclude binaries in my test suite. Of course I could just not run it with go test -race but I'd have to rewrite part of our test pipeline and thus selectively disabling on a binary would make more sense.

2

There are 2 answers

0
hbogert On

If the reason is that you want to not fail on the race detector, then use

$ GORACE="exitcode=0" [ go ... | ./compiled-test-bin ]
0
Volker On

Is there a way to disable the data race checking in a compiled test binary?

No.

The race detector either is compiled in or not compiled in.