Source File
rand.go
Belonging Package
github.com/redis/go-redis/v9/internal/rand
package randimport ()// Int returns a non-negative pseudo-random int.func () int { return pseudo.Int() }// Intn returns, as an int, a non-negative pseudo-random number in [0,n).// It panics if n <= 0.func ( int) int { return pseudo.Intn() }// Int63n returns, as an int64, a non-negative pseudo-random number in [0,n).// It panics if n <= 0.func ( int64) int64 { return pseudo.Int63n() }// Perm returns, as a slice of n ints, a pseudo-random permutation of the integers [0,n).func ( int) []int { return pseudo.Perm() }// Seed uses the provided seed value to initialize the default Source to a// deterministic state. If Seed is not called, the generator behaves as if// seeded by Seed(1).func ( int64) { pseudo.Seed() }var pseudo = rand.New(&source{src: rand.NewSource(1)})type source struct {src rand.Sourcemu sync.Mutex}func ( *source) () int64 {.mu.Lock():= .src.Int63().mu.Unlock()return}func ( *source) ( int64) {.mu.Lock().src.Seed().mu.Unlock()}// Shuffle pseudo-randomizes the order of elements.// n is the number of elements.// swap swaps the elements with indexes i and j.func ( int, func(, int)) { pseudo.Shuffle(, ) }
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |