How do I run a go test using bazel with the -race option?

Viewed 2042

In go, I can enable the race detector for tests using the -race option e.g.

go test -race ./foo/bar

How do I do this in bazel?

2 Answers

Use --@io_bazel_rules_go//go/config:race (docs) as a flag to bazel test.

--features=race is no longer supported and the test will warn about not being supported.

bazel test --@io_bazel_rules_go//go/config:race //src/foo/bar
Related