mirror of
https://github.com/tiennm99/hugoDocs.git
synced 2026-10-14 14:17:43 +00:00
tpl/collections: Seed random on init only
This commit is contained in:
1 parent
ed4a00e46f
commit
83c761b71a
1 file changed
+4
-1
@@ -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