math/rand

Guided tour · Math · pkg.go.dev →

Legacy pseudo-random package. Prefer math/rand/v2 in new code. Keep this around only for unchanged legacy APIs.

Why prefer v2?

math/rand has a global mutex (serializes goroutine calls), needed explicit seeding before Go 1.20, and has a bigger, messier API. math/rand/v2 fixes all three. See the math/rand/v2 page on this site.