mirror of
https://github.com/navidrome/navidrome.git
synced 2025-05-02 19:31:45 +03:00
Refer to https://support.symfonium.app/t/symfonium-sync-crashes-when-tpos-is-not-an-int/4204
20 lines
311 B
Go
20 lines
311 B
Go
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)
|
|
}
|