mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-16 20:53:59 +02:00
tpl/collections: Seed random on init only
This commit is contained in:
committed by
Bjørn Erik Pedersen
parent
ed4a00e46f
commit
83c761b71a
@@ -29,6 +29,10 @@ import (
|
|||||||
"github.com/spf13/cast"
|
"github.com/spf13/cast"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
rand.Seed(time.Now().UTC().UnixNano())
|
||||||
|
}
|
||||||
|
|
||||||
// New returns a new instance of the collections-namespaced template functions.
|
// New returns a new instance of the collections-namespaced template functions.
|
||||||
func New(deps *deps.Deps) *Namespace {
|
func New(deps *deps.Deps) *Namespace {
|
||||||
return &Namespace{
|
return &Namespace{
|
||||||
@@ -474,7 +478,6 @@ func (ns *Namespace) Shuffle(seq interface{}) (interface{}, error) {
|
|||||||
|
|
||||||
shuffled := reflect.MakeSlice(reflect.TypeOf(seq), seqv.Len(), seqv.Len())
|
shuffled := reflect.MakeSlice(reflect.TypeOf(seq), seqv.Len(), seqv.Len())
|
||||||
|
|
||||||
rand.Seed(time.Now().UTC().UnixNano())
|
|
||||||
randomIndices := rand.Perm(seqv.Len())
|
randomIndices := rand.Perm(seqv.Len())
|
||||||
|
|
||||||
for index, value := range randomIndices {
|
for index, value := range randomIndices {
|
||||||
|
Reference in New Issue
Block a user