package random

import "github.com/antithesishq/antithesis-sdk-go/random"

Package random is part of the Antithesis Go SDK, which enables Go applications to integrate with the Antithesis platform.

These functions should not be used to seed a conventional PRNG, and should not have their return values stored and used to make a decision at a later time. Doing either of these things makes it much harder for the Antithesis platform to control the history of your program's execution, and also makes it harder for Antithesis to learn which inputs provided at which times are most fruitful. Instead, you should call a function from the random package every time your program or workload needs to make a decision, at the moment that you need to make the decision.

These functions are also safe to call outside the Antithesis environment, where they will fall back on values from crypto/rand.

Index

Functions

func GetRandom deprecated

func GetRandom() uint64

GetRandom returns a uint64 value chosen by Antithesis. You should not store this value or use it to seed a PRNG, but should use it immediately.

Deprecated: Use Source instead of calling this function directly.

func RandomChoice

func RandomChoice[T any](things []T) T

RandomChoice returns a randomly chosen item from a list of options. You should not store this value, but should use it immediately.

This function is not purely for convenience. Signaling to the Antithesis platform that you intend to use a random value in a structured way enables it to provide more interesting choices over time.

func Source

func Source() rand.Source

Source initialises a source of pseudo-random data.

Use this function to create a math/rand.Rand which provides feedback to the Antithesis platform.

The returned source implements math/rand.Source64.