mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-14 23:17:33 +08:00
17 lines
235 B
Go
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
|
|
}
|