Documentation ¶
Overview ¶
Package stablerand is a small helper utility that encapsulates its random engine and always uses the same seed value for its randomness.
This ensures reproducibility and stability across executions, giving a pseudo-random distribution, but with deterministic predictability. This is primarily intended for generating content for tests, which ensures that inputs are still pseudo-random, but predictible and consistent across unchanged executions.
Functions in this package are thread-safe, although use in threaded contexts will remove any guarantees of determinism.
Note: This is primarily used internally for the fhirtest package to implement "random" IDs and meta-IDs so that test resources retain the same general values across executions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AlnumString ¶
AlnumString returns, as a string, a pseudo-random string containing n alphanumeric characters.
func DecString ¶
DecString returns, as a string, a pseudo-random string containing n decimal characters.
func HexString ¶
HexString returns, as a string, a pseudo-random string containing n hex characters.
func Int63n ¶
Int63n returns, as an int64, a non-negative pseudo-random number in the half-open interval [0,n). It panics if n <= 0.
func Intn ¶
Intn returns, as an int, a non-negative pseudo-random number in the half-open interval [0,n). It panics if n <= 0.
func OneOf ¶
func OneOf[T any](args ...T) T
OneOf returns, as a T object, a pseudo-randomly selected value from args. It panics if args is empty.
Types ¶
This section is empty.