math/rand: Add auto-seed info to deprecation notice #59331
Labels
Documentation
Issues describing a change to documentation.
FrozenDueToAge
help wanted
NeedsFix
The path to resolution is known, but the work has not been done.
The current deprecation notice on rand.Seed only addresses what I think is a tiny corner case for why most applications call rand.Seed.
The thing is, since the beginning of time, many applications have been calling
rand.Seed
on startup because otherwisemath/rand
got seeded with a static value. So they actually wanted the opposite of what this deprecation notice says. Which makes this deprecation notice very confusing.I know that there is a sentence above the notice in the docs that states that the seed is now set randomly at program startup, but many automated tools simply extract the deprecation notice to display to the developer, and the existing notice only applies to what I expect is about 0.1% of usage, and says nothing about the 99.9% case, where a dev was doing the (previously, mostly) right thing, and calling something like
rand.Seed(time.Now().UnixNano())
.One more short sentence at the beginning of the deprecation notice would save a lot of confusion. Something like this:
Personally, I think the existing deprecation notice is too long and editorializes too much about what could go wrong. I'd skip right to the important bits:
(also note that the current documentation has a typo in the deprecation notice where it says
NewRand(
but should sayNew(
)What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
The text was updated successfully, but these errors were encountered: