Skip to content

Instantly share code, notes, and snippets.

@jcsalem
Created March 1, 2017 21:31
Show Gist options
  • Save jcsalem/28133cc6a1dd730bf4ac010de98a0e89 to your computer and use it in GitHub Desktop.
Save jcsalem/28133cc6a1dd730bf4ac010de98a0e89 to your computer and use it in GitHub Desktop.
No race condition
package main_test
import (
"testing"
"time"
)
func TestRaceys(t *testing.T) {
var race bool
go func() {
for i := 0; i < 100000; i++ {
race = true
race = false
}
}()
go func() {
for i := 0; i < 100000; i++ {
if race {
}
}
}()
time.Sleep(time.Second * 2)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment