github.com/rjgonzale/pop/v5@v5.1.3-dev/internal/randx/randx.go (about) 1 package randx 2 3 import ( 4 "math/rand" 5 "sync" 6 "time" 7 ) 8 9 func init() { 10 rand.Seed(time.Now().UnixNano()) 11 } 12 13 type safeSrc struct { 14 src rand.Source 15 moot sync.Mutex 16 } 17 18 func (s *safeSrc) Int63() int64 { 19 s.moot.Lock() 20 n := s.src.Int63() 21 s.moot.Unlock() 22 return n 23 } 24 25 func newSafeSrc(s rand.Source) *safeSrc { 26 return &safeSrc{ 27 src: s, 28 moot: sync.Mutex{}, 29 } 30 }