diff options
author | liguoqinjim <liguoqinjim23@gmail.com> | 2018-01-28 01:51:12 +0800 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-01-27 18:51:12 +0100 |
commit | 83c761b71a980aee6331179b271c7e24e999e8eb (patch) | |
tree | 026c7282fe0e4e791a8e1935942a4769112563cb /tpl | |
parent | ed4a00e46f2344320a22f07febe5aec4075cb3fb (diff) |
tpl/collections: Seed random on init only
Diffstat (limited to 'tpl')
-rw-r--r-- | tpl/collections/collections.go | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/tpl/collections/collections.go b/tpl/collections/collections.go index 34b8e7f77..d1b97677f 100644 --- a/tpl/collections/collections.go +++ b/tpl/collections/collections.go @@ -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 { |