1
0
Fork 0
mirror of https://github.com/gohugoio/hugo.git synced 2025-04-10 09:27:52 +00:00

resources: Use default math/rand.Source for concurrency safety

The source from NewSource is documented not to be safe for
concurrency, and instead use the eefault source which is documented
as safe.

Fixes 
This commit is contained in:
Emmanuel T Odeke 2021-09-19 04:18:30 -06:00 committed by GitHub
parent 13ad8408fc
commit 7c21eca74f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -19,7 +19,6 @@ import (
"path/filepath"
"strings"
"testing"
"time"
"github.com/spf13/afero"
@ -189,11 +188,10 @@ func TestResourcesGetMatch(t *testing.T) {
func BenchmarkResourcesMatch(b *testing.B) {
resources := benchResources(b)
prefixes := []string{"abc*", "jkl*", "nomatch*", "sub/*"}
rnd := rand.New(rand.NewSource(time.Now().Unix()))
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
resources.Match(prefixes[rnd.Intn(len(prefixes))])
resources.Match(prefixes[rand.Intn(len(prefixes))])
}
})
}