mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-14 08:32:54 +00: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"
|
"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 {
|
||||||
|
|
Loading…
Add table
Reference in a new issue