mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-03 20:47:35 +03:00
Add function number.RandomInt64
This commit is contained in:
parent
7a617d3a1d
commit
7fbcb2904a
3 changed files with 17 additions and 10 deletions
|
@ -1,6 +1,11 @@
|
|||
package number
|
||||
|
||||
import "golang.org/x/exp/constraints"
|
||||
import (
|
||||
"crypto/rand"
|
||||
"math/big"
|
||||
|
||||
"golang.org/x/exp/constraints"
|
||||
)
|
||||
|
||||
func Min[T constraints.Ordered](vs ...T) T {
|
||||
if len(vs) == 0 {
|
||||
|
@ -29,3 +34,8 @@ func Max[T constraints.Ordered](vs ...T) T {
|
|||
}
|
||||
return max
|
||||
}
|
||||
|
||||
func RandomInt64(max int64) int64 {
|
||||
rnd, _ := rand.Int(rand.Reader, big.NewInt(max))
|
||||
return rnd.Int64()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue