Skip to content

Commit

Permalink
resources: use default math/rand.Source for concurrency safety
Browse files Browse the repository at this point in the history
The source from NewSource is documented not to be safe for
concurrency, and instead use the eefault source which is documented
as safe.

Fixes gohugoio#8981
  • Loading branch information
odeke-em committed Sep 19, 2021
1 parent 13ad840 commit a90cd50
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions resources/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"path/filepath"
"strings"
"testing"
"time"

"github.com/spf13/afero"

Expand Down Expand Up @@ -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))])
}
})
}
Expand Down

0 comments on commit a90cd50

Please sign in to comment.