Skip to content

random-bound-one

Default severity: warning

Bounded random integer functions generate values in the half-open range from zero up to, but excluding, the bound. A bound of one therefore always returns zero.

choice := rand.Intn(1)
choice := rand.Intn(2)

The check covers package functions and Rand methods in both standard random packages.