Created
June 11, 2018 18:22
-
-
Save cep21/ce8262b35d44eb4bc7060e473419c8fa to your computer and use it in GitHub Desktop.
A -race failing test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"testing" | |
"sync" | |
) | |
func TestAppend(t *testing.T) { | |
x := make([]string, 0, 6) | |
wg := sync.WaitGroup{} | |
wg.Add(2) | |
go func() { | |
defer wg.Done() | |
y := append(x, "hello", "world") | |
t.Log(len(y)) | |
}() | |
go func() { | |
defer wg.Done() | |
z := append(x, "goodbye", "bob") | |
t.Log(len(z)) | |
}() | |
wg.Wait() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment