Use goroutine-safe version of rand.Source
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
This commit is contained in:
parent
31232249f7
commit
66d8f1a5ea
4 changed files with 64 additions and 6 deletions
22
random/random_test.go
Normal file
22
random/random_test.go
Normal file
|
@ -0,0 +1,22 @@
|
|||
package random
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"sync"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// for go test -v -race
|
||||
func TestConcurrency(t *testing.T) {
|
||||
rnd := rand.New(NewSource())
|
||||
var wg sync.WaitGroup
|
||||
|
||||
for i := 0; i < 10; i++ {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
rnd.Int63()
|
||||
wg.Done()
|
||||
}()
|
||||
}
|
||||
wg.Wait()
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue