Documentation ¶
Overview ¶
Package generate is for generating random data from given structures
Index ¶
- func AssignMaxLen(cfg *Config)
- func AssignSeed(cfg *Config)
- func AssignUseRandomType(cfg *Config)
- type Config
- type TabularGenerator
- type ValueGenerator
- func (g *ValueGenerator) Array() []interface{}
- func (g *ValueGenerator) Bool() bool
- func (g *ValueGenerator) Float() float64
- func (g *ValueGenerator) Int() int
- func (g *ValueGenerator) Object() map[string]interface{}
- func (g *ValueGenerator) String() string
- func (g *ValueGenerator) Type(t string) interface{}
- func (g *ValueGenerator) Value() interface{}
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssignMaxLen ¶
func AssignMaxLen(cfg *Config)
AssignMaxLen sets a maximum length for generated values.
func AssignUseRandomType ¶
func AssignUseRandomType(cfg *Config)
AssignUseRandomType causes generator to generate random types of values.
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config stores settings for the generate package.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns the default configuration for a Generator.
type TabularGenerator ¶ added in v0.2.0
type TabularGenerator struct {
// contains filtered or unexported fields
}
TabularGenerator is a dsio.EntryReader that creates a new entry on each call to ReadEntry
func NewTabularGenerator ¶ added in v0.2.0
func NewTabularGenerator(st *dataset.Structure, options ...func(*Config)) (*TabularGenerator, error)
NewTabularGenerator creates a tablular data generator with the given configuration options
func (TabularGenerator) Close ¶ added in v0.2.0
func (g TabularGenerator) Close() error
Close finalizes the generator
func (*TabularGenerator) ReadEntry ¶ added in v0.2.0
func (g *TabularGenerator) ReadEntry() (dsio.Entry, error)
ReadEntry implements the dsio.EntryReader interface
func (TabularGenerator) Structure ¶ added in v0.2.0
func (g TabularGenerator) Structure() *dataset.Structure
Structure implements the dsio.EntryReader interface
type ValueGenerator ¶ added in v0.2.0
ValueGenerator is a state machine for producing values
func (*ValueGenerator) Array ¶ added in v0.2.0
func (g *ValueGenerator) Array() []interface{}
Array creates an empty array TODO (b5) - populate with random values
func (*ValueGenerator) Bool ¶ added in v0.2.0
func (g *ValueGenerator) Bool() bool
Bool yields a random coin flip
func (*ValueGenerator) Float ¶ added in v0.2.0
func (g *ValueGenerator) Float() float64
Float yields a random floating point number
func (*ValueGenerator) Int ¶ added in v0.2.0
func (g *ValueGenerator) Int() int
Int yields a random integer
func (*ValueGenerator) Object ¶ added in v0.2.0
func (g *ValueGenerator) Object() map[string]interface{}
Object creates an empty object TODO (b5) - populate with random values
func (*ValueGenerator) String ¶ added in v0.2.0
func (g *ValueGenerator) String() string
String yields a random string
func (*ValueGenerator) Type ¶ added in v0.2.0
func (g *ValueGenerator) Type(t string) interface{}
Type creates a value to match a string type. type names match the JSON-schema specification
func (*ValueGenerator) Value ¶ added in v0.2.0
func (g *ValueGenerator) Value() interface{}
Value creates a random value of a random type