In Go, to detect data race, we can use the -race flag when running or testing our code.

1
go run -race main.go