go随聊-随机数包fastrand

fastrand

go get github.com/NebulousLabs/fastrand

fastrand implements a cryptographically secure pseudorandom number generator. The generator is seeded using the system's default entropy source, and thereafter produces random values via repeated hashing. As a result, fastrand can generate randomness much faster than crypto/rand, and generation cannot fail beyond a potential panic during init().

fastrand also scales better than crypto/rand and math/rand when called in parallel. In fact, fastrand can even outperform math/rand when using enough threads.

例子

返回随机数(x~maxN)
fastrand.Uint32n(maxN uint32) uint32

返回随机数
fastrand.Uint32() uint32

go随聊-随机数包fastrand