Source File
rand.go
Belonging Package
math/rand
package rand
import
for := 0; < ; ++ {
:= .Intn( + 1)
[] = []
[] =
}
return
}
func ( *Rand) ( []byte) ( int, error) {
if , := .src.(*lockedSource); {
return .read(, &.readVal, &.readPos)
}
return read(, .src, &.readVal, &.readPos)
}
func ( []byte, Source, *int64, *int8) ( int, error) {
:= *
:= *
, := .(*rngSource)
for = 0; < len(); ++ {
if == 0 {
if != nil {
= .Int63()
} else {
= .Int63()
}
= 7
}
[] = byte()
>>= 8
--
}
* =
* =
return
}
var globalRand = New(&lockedSource{src: NewSource(1).(*rngSource)})
var _ *rngSource = globalRand.src.(*lockedSource).src
func ( int64) { globalRand.Seed() }
func () int64 { return globalRand.Int63() }
func () uint32 { return globalRand.Uint32() }
func () uint64 { return globalRand.Uint64() }
func () int32 { return globalRand.Int31() }
func () int { return globalRand.Int() }
func ( int64) int64 { return globalRand.Int63n() }
func ( int32) int32 { return globalRand.Int31n() }
func ( int) int { return globalRand.Intn() }
func () float64 { return globalRand.Float64() }
func () float32 { return globalRand.Float32() }
func ( int) []int { return globalRand.Perm() }
func ( int, func(, int)) { globalRand.Shuffle(, ) }
func ( []byte) ( int, error) { return globalRand.Read() }
func () float64 { return globalRand.NormFloat64() }
func () float64 { return globalRand.ExpFloat64() }
type lockedSource struct {
lk sync.Mutex
src *rngSource
}
func ( *lockedSource) () ( int64) {
.lk.Lock()
= .src.Int63()
.lk.Unlock()
return
}
func ( *lockedSource) () ( uint64) {
.lk.Lock()
= .src.Uint64()
.lk.Unlock()
return
}
func ( *lockedSource) ( int64) {
.lk.Lock()
.src.Seed()
.lk.Unlock()
}
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin 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 @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |