Created
June 12, 2018 00:23
-
-
Save cep21/27f2b5ea9f9baddd98a882ded489e80c to your computer and use it in GitHub Desktop.
workaround
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 ( | |
"sync" | |
"testing" | |
) | |
func TestAppend(t *testing.T) { | |
x := make([]string, 0, 6) | |
x = append(x, "start") | |
wg := sync.WaitGroup{} | |
wg.Add(2) | |
go func() { | |
defer wg.Done() | |
y := make([]string, 0, len(x)+2) | |
y = append(y, x...) | |
y = append(y, "hello", "world") | |
t.Log(cap(y), len(y), y[0]) | |
}() | |
go func() { | |
defer wg.Done() | |
z := make([]string, 0, len(x)+2) | |
z = append(z, x...) | |
z = append(z, "goodbye", "bob") | |
t.Log(cap(z), len(z), z[0]) | |
}() | |
wg.Wait() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment