mmcgrana / gobyexample

Go by Example
https://gobyexample.com
7.16k stars 1.26k forks source link

Default number generator is no longer deterministic #506

Closed InPermutation closed 7 months ago

InPermutation commented 7 months ago

https://gobyexample.com/random-numbers says,

The default number generator is deterministic, so it’ll produce the same sequence of numbers each time by default. To produce varying sequences, give it a seed that changes.

However, the current docs for rand.Seed say,

func Seed DEPRECATED … If Seed is not called, the generator is seeded randomly at program startup.

Prior to Go 1.20, the generator was seeded like Seed(1) at program startup.

So, it's no longer true that the default number generator is deterministic.

I'm not sure how to best update the verbiage, so I opened this issue for discussion.

eliben commented 7 months ago

Thanks for the report; this is now fixed.

Separately, #507 will track the update to math/rand/v2 once Go 1.22 is out