Refactor random functions

This commit is contained in:
Deluan
2024-05-11 20:04:21 -04:00
parent 30ae468dc1
commit 0ae2944073
10 changed files with 53 additions and 19 deletions
-7
View File
@@ -1,18 +1,11 @@
package number
import (
"crypto/rand"
"math/big"
"strconv"
"golang.org/x/exp/constraints"
)
func RandomInt64(max int64) int64 {
rnd, _ := rand.Int(rand.Reader, big.NewInt(max))
return rnd.Int64()
}
func ParseInt[T constraints.Integer](s string) T {
r, _ := strconv.ParseInt(s, 10, 64)
return T(r)