Fix int types in OpenSubsonic responses.

Refer to https://support.symfonium.app/t/symfonium-sync-crashes-when-tpos-is-not-an-int/4204
This commit is contained in:
Deluan
2024-05-01 13:57:11 -04:00
parent 7ab7b5df5e
commit 2c06a4234e
4 changed files with 39 additions and 14 deletions
+8
View File
@@ -3,9 +3,17 @@ 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)
}