mirror of
https://github.com/samber/lo.git
synced 2026-04-22 23:47:11 +08:00
refactor:refactor RandomString function (#524)
* refactor:refactor RandomString function * feat:Upgrade math/rand to math/rand/v2 * Update string.go Co-authored-by: ccoVeille <3875889+ccoVeille@users.noreply.github.com> * feat: improve comments for RandomString function * Update string.go Co-authored-by: Samuel Berthe <dev@samuel-berthe.fr> * feat:Upgrade math/rand/v2 to github.com/samber/lo/internal/rand * Update string.go * Update ordered_go118.go --------- Co-authored-by: zhuhebin <zhuhebin@fengtaisec.com> Co-authored-by: ccoVeille <3875889+ccoVeille@users.noreply.github.com> Co-authored-by: Samuel Berthe <dev@samuel-berthe.fr>
This commit is contained in:
@@ -12,3 +12,15 @@ func IntN(n int) int {
|
||||
// bearer:disable go_gosec_crypto_weak_random
|
||||
return rand.Intn(n)
|
||||
}
|
||||
|
||||
func Int64() int64 {
|
||||
// bearer:disable go_gosec_crypto_weak_random
|
||||
n := rand.Int63()
|
||||
|
||||
// bearer:disable go_gosec_crypto_weak_random
|
||||
if rand.Intn(2) == 0 {
|
||||
return -n
|
||||
}
|
||||
|
||||
return n
|
||||
}
|
||||
|
||||
@@ -11,3 +11,7 @@ func Shuffle(n int, swap func(i, j int)) {
|
||||
func IntN(n int) int {
|
||||
return rand.IntN(n)
|
||||
}
|
||||
|
||||
func Int64() int64 {
|
||||
return rand.Int64()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user