mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
tpl/collections: Seed random on init only
This commit is contained in:
parent
ed4a00e46f
commit
83c761b71a
1 changed files with 4 additions and 1 deletions
|
@ -29,6 +29,10 @@ import (
|
|||
"github.com/spf13/cast"
|
||||
)
|
||||
|
||||
func init() {
|
||||
rand.Seed(time.Now().UTC().UnixNano())
|
||||
}
|
||||
|
||||
// New returns a new instance of the collections-namespaced template functions.
|
||||
func New(deps *deps.Deps) *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())
|
||||
|
||||
rand.Seed(time.Now().UTC().UnixNano())
|
||||
randomIndices := rand.Perm(seqv.Len())
|
||||
|
||||
for index, value := range randomIndices {
|
||||
|
|
Loading…
Reference in a new issue