generate

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 2021 License: MIT Imports: 6 Imported by: 1

Documentation

Overview

Package generate is for generating random data from given structures

Index

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 AssignSeed

func AssignSeed(cfg *Config)

AssignSeed sets a specific random seed to be used.

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

type ValueGenerator struct {
	Rand            *rand.Rand // random number generator
	MaxStringLength int
}

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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