util/rand: replace all non crypto rand stuff with own rand package

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2021-02-17 22:58:55 +03:00
parent 67748a2132
commit 5596345382
6 changed files with 99 additions and 23 deletions

View File

@@ -1,9 +1,8 @@
package random
import (
"math/rand"
"github.com/unistack-org/micro/v3/selector"
"github.com/unistack-org/micro/v3/util/rand"
)
type random struct{}
@@ -20,10 +19,9 @@ func (r *random) Select(routes []string, opts ...selector.SelectOption) (selecto
if len(routes) == 1 {
return routes[0]
}
var rng rand.Rand
// select a random route from the slice
//nolint:gosec
return routes[rand.Intn(len(routes))]
return routes[rng.Intn(len(routes))]
}, nil
}