[#401] internal: Place randomization code in random package

Also replace seeding into `init` function.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2022-05-30 21:49:30 +03:00 committed by LeL
parent 02e962f727
commit c82dcf7e16
4 changed files with 22 additions and 19 deletions

15
internal/random/rand.go Normal file
View file

@ -0,0 +1,15 @@
package random
import (
"math/rand"
"time"
)
func init() {
rand.Seed(time.Now().UnixNano())
}
// Uint32 returns random uint32 value [0, max).
func Uint32(max uint32) uint32 {
return rand.Uint32() % max
}