Files
ezbookkeeping/pkg/utils/numbers.go
T
2020-10-17 22:02:50 +08:00

17 lines
235 B
Go

package utils
import (
"crypto/rand"
"math/big"
)
func GetRandomInteger(max int) (int, error) {
result, err := rand.Int(rand.Reader, big.NewInt(int64(max)))
if err != nil {
return 0, err
}
return int(result.Int64()), nil
}