5 ms·
> So, if I use `math/rand` the RNG will always output the same sequence of random numbers? math/rand provides global functions using a global RNG, as well as
by chimeracoder 4y ago
> So, if I use `math/rand` the RNG will always output the same sequence of random numbers?
math/rand provides global functions using a global RNG, as well as the ability to instantiate your own RNG and call functions (methods) on that RNG.
Previously, the global functions all used a seed of 1, which made them generate identical sequences. Now, they use random seed, which makes them less-easily predictable (though still predictable).
There is no change to the self-instantiated RNGs.
> How do I make sure I'm passing a random seed to my RNG?
With the change, using the global functions in Go 1.20+ is the same as instantiating your own RNG with a random seed.