Skip to content

Instantly share code, notes, and snippets.

@cep21
Created June 11, 2018 18:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cep21/ce8262b35d44eb4bc7060e473419c8fa to your computer and use it in GitHub Desktop.
Save cep21/ce8262b35d44eb4bc7060e473419c8fa to your computer and use it in GitHub Desktop.
A -race failing test
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