Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
math/rand: default Source safe for concurrent use #12471
This confused me because I thought the "default Source" referred to Source returned by the NewSource function. Instead, it refers to the protected internal Source used by the top-level functions.
I think the docs about default Source is pretty clear if you read it in full. ``` Top-level functions, such as Float64 and Int, use a default shared Source that produces a deterministic sequence of values each time a program is run. Use the Seed function to initialize the default Source if different behavior is required for each run. The default Source is safe for concurrent use by multiple goroutines. ``` It explicitly mentions the default Source is the one used by the top-level functions. Following Go documentation convention, anything not explicitly documented for concurrency safety is not safe for concurrent use. The NewSource doesn't say Source is safe for concurrent use, so it's not.