rand

package
v1.0.77 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 29, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func N

func N[T constraints.Integer](n T) T

N generates a random non-negative integer within the range [0, max). The generated integer will be less than the provided maximum value. If max is less than or equal to 0, the function will treat it as if max is 1.

Usage:

n := 10
randomInt := rand.N(n)
fmt.Printf("Random integer between 0 and %d: %d\n", max, randomInt)

Parameters:

  • n (int): The maximum bound for the random integer to be generated.

Returns:

  • int: A random non-negative integer within the specified range.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL