diff --git a/random/random.go b/random/random.go index 6e0c8cf..230feb6 100644 --- a/random/random.go +++ b/random/random.go @@ -17,7 +17,7 @@ import ( ) const ( - MaximumCapacity = 1 << 31 + MaximumCapacity = math.MaxInt>>1 + 1 Numeral = "0123456789" LowwerLetters = "abcdefghijklmnopqrstuvwxyz" UpperLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" @@ -157,7 +157,7 @@ func random(s string, length int) string { cache, remain = rn.Int63(), letterIdMax } // 从可用字符的字符串中随机选择一个字符 - if idx := int(cache & letterIdMask); idx < len(s) { + if idx := int(cache & letterIdMask); idx < strLength { bytes[i] = s[idx] i-- }