quintodrome/utils/random/number.go

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

14 lines
216 B
Go
Raw Normal View History

2024-05-11 16:04:21 -08:00
package random
import (
"crypto/rand"
"math/big"
"golang.org/x/exp/constraints"
2024-05-11 16:04:21 -08:00
)
func Int64[T constraints.Integer](max T) int64 {
rnd, _ := rand.Int(rand.Reader, big.NewInt(int64(max)))
2024-05-11 16:04:21 -08:00
return rnd.Int64()
}