gen

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package gen is the engine: schema.Schema + rng → records. It knows nothing about Go structs — it produces map[string]any keyed by field name, which the public API scatters back into T.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

type Engine struct {

	// Chaos is the probability [0,1] that a string/numeric field carries an
	// edge-case value instead of a normal one (see WithChaos).
	Chaos float64
	// contains filtered or unexported fields
}

Engine holds a compiled, validated schema ready to generate records.

func Compile

func Compile(s *schema.Schema, localeName string) (*Engine, error)

Compile validates the schema (unknown kinds, from= cycles) and computes the field generation order once. Returns an error for configuration problems.

func (*Engine) Err added in v1.5.0

func (e *Engine) Err() error

Err reports the first error hit while generating records, if any. Record cannot return one, so callers that can surface an error check this after their generation loop.

func (*Engine) HasUnique

func (e *Engine) HasUnique() bool

HasUnique reports whether any field requires unique values. Unique tracking is stateful, so callers must use serial generation when this is true.

func (*Engine) Record

func (e *Engine) Record(base *rng.Rand, seq int) map[string]any

Record generates one record. seq is the record index, used with the base rng to fork a deterministic per-record stream.

func (*Engine) Schema

func (e *Engine) Schema() *schema.Schema

Schema exposes the underlying schema (for encoders needing column order).

Jump to

Keyboard shortcuts

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