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: Intn(<=0) returns unexpected result #2892
If the interval [0, n) is empty, math.Intn(n) returns 0, which is not in the interval. I'd prefer a panic("math.Intn(non-positive integer)"), but even changing the documentation would be better. E.g., "If the interval is empty the result is not defined, or there might be a panic."