run-race.sh 630 B

123456789101112131415
  1. #!/bin/sh
  2. # Prints "-race" if running on a platform that supports the race detector.
  3. # This should be kept in sync with the official list here:
  4. # https://golang.org/doc/articles/race_detector#Requirements
  5. if test `go env CGO_ENABLED` = 1; then
  6. if echo `go env GOOS GOARCH` |
  7. egrep -qx '((linux|darwin|freebsd|netbsd) amd64|(linux|darwin) arm64|linux ppc64le)'; then
  8. printf %s -race
  9. elif echo `go env GOOS GOARCH` | egrep -qx 'windows amd64'; then
  10. # Race detector on Windows AMD64 requires gcc: https://github.com/golang/go/issues/27089
  11. if which gcc > /dev/null 2>&1; then
  12. printf %s -race
  13. fi
  14. fi
  15. fi