Go test -race requires CGO_ENABLED=1

Sun, May 1, 2022 One-minute read

Go test -race requires CGO_ENABLED=1

To run go test -race CGO_ENABLED=1 must be set. I do not use CGO as I do not want any linking.

The workaround is simple, export it for that command.

CGO_ENABLED=1 go test -race ./...

Tags:

#golang #cgo #testing