---
title: "random-bound-one"
description: "Detect random integer calls whose upper bound permits only zero."
image: "https://strider.gempir.com/og.png"
---

> Documentation Index
> Fetch the complete documentation index at: https://strider.gempir.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 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.

## Bad

```go
choice := rand.Intn(1)
```

## Good

```go
choice := rand.Intn(2)
```

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

Source: https://strider.gempir.com/analyzers/random-bound-one/index.mdx
