Skip to content

Commit

Permalink
Update rand/source
Browse files Browse the repository at this point in the history
  • Loading branch information
itsubaki committed Apr 6, 2024
1 parent 5d6f7d0 commit 6bec448
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions rand/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ package rand

import (
crand "crypto/rand"
"math/rand/v2"
randv2 "math/rand/v2"
)

// NewSource returns a source of pseudo-random number generator
func NewSource() rand.Source {
func NewSource() randv2.Source {
var p [32]byte
if _, err := crand.Read(p[:]); err != nil {
panic(err)
}

return rand.NewChaCha8(p)
return randv2.NewChaCha8(p)
}

// Const returns a source of constant pseudo-random number generator
func Const(seed ...uint64) rand.Source {
func Const(seed ...uint64) randv2.Source {
var s0, s1 uint64
if len(seed) > 0 {
s0 = seed[0]
Expand All @@ -26,5 +26,5 @@ func Const(seed ...uint64) rand.Source {
s1 = seed[1]
}

return rand.NewPCG(s0, s1)
return randv2.NewPCG(s0, s1)
}

0 comments on commit 6bec448

Please sign in to comment.