fakedata

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecuteTemplate added in v1.0.0

func ExecuteTemplate(tmpl string, n int, streamMode bool) (err error)

ExecuteTemplate takes a tmpl string and a n int and generates n rows of based on the specified tmpl. Will loop forever if streamMode is true

func GetCompletionFunc added in v1.1.0

func GetCompletionFunc(shell string) (string, error)

GetCompletionFunc returns a string representing a completion function for the given shell. It returns an error for unsupported shell.

Types

type Column added in v0.2.0

type Column struct {
	Name     string
	Key      string
	Generate func() string
}

A Column represents one field of data to generate

type ColumnFormatter added in v1.2.0

type ColumnFormatter struct {
	Separator string
}

ColumnFormatter is a Formatter for character separated formats

func NewColumnFormatter added in v1.2.0

func NewColumnFormatter(sep string) (f *ColumnFormatter)

NewColumnFormatter returns a ColumnFormatter using the sep string as a separator

func (*ColumnFormatter) Format added in v1.2.0

func (f *ColumnFormatter) Format(columns Columns, values []string) string

Format as character separated strings

type Columns added in v0.2.0

type Columns []Column

Columns is an array of Column

func NewColumns added in v0.2.0

func NewColumns(keys []string) (cols Columns, err error)

NewColumns returns an array of Columns using keys as a specification. It returns an error with a line for each unknown key

func (Columns) GenerateHeader added in v1.4.0

func (columns Columns) GenerateHeader(f io.Writer, formatter Formatter)

GenerateRow generates an header row using column names in the specified format

func (Columns) GenerateRow added in v1.0.0

func (columns Columns) GenerateRow(f io.Writer, formatter Formatter)

GenerateRow generates a row of fake data using columns in the specified format

type Formatter added in v0.2.0

type Formatter interface {
	Format(Columns, []string) string
}

Formatter is the interface wraps the Format method we use to format each row

type Generator added in v0.2.0

type Generator struct {
	Func       func() string
	CustomFunc func(string) (func() string, error)
	Desc       string
	Name       string
	Hidden     bool
}

A Generator is a func that generates random data along with its description

func (Generator) IsCustom added in v1.0.0

func (g Generator) IsCustom() bool

IsCustom returns a bool indicating whether the generator has a CustomFunc or not

type Generators added in v0.2.0

type Generators []Generator

Generators is an array of Generator

func NewGenerators added in v1.0.0

func NewGenerators() (gens Generators)

NewGenerators returns the available generators

func (Generators) FindByName added in v1.0.0

func (gens Generators) FindByName(name string) (gen *Generator)

FindByName returns, if present, the generator with the name string

func (Generators) Visible added in v1.5.0

func (gens Generators) Visible() (newGens Generators)

Visible returns only the generators that should appear in the help list

func (Generators) WithConstraints added in v1.0.0

func (gens Generators) WithConstraints() (newGens Generators)

WithConstraints returns only the generators that accept constraints

type NdjsonFormatter added in v1.4.0

type NdjsonFormatter struct {
}

NdJsonFormatter is a Formatter for http://ndjson.org/

func NewNdjsonFormatter added in v1.4.0

func NewNdjsonFormatter() (f *NdjsonFormatter)

NewNdjsonFormatter returns a NdjsonFormatter

func (*NdjsonFormatter) Format added in v1.4.0

func (f *NdjsonFormatter) Format(columns Columns, values []string) string

Format as ndjson

type SQLFormatter added in v0.2.0

type SQLFormatter struct {
	Table string
}

SQLFormatter is a Formatter for the SQL insert statement

func NewSQLFormatter added in v0.2.0

func NewSQLFormatter(table string) (f *SQLFormatter)

NewSQLFormatter returns a SQLFormatter using the table string for table name generation

func (*SQLFormatter) Format added in v0.2.0

func (f *SQLFormatter) Format(columns Columns, values []string) string

Format as SQL statements

Jump to

Keyboard shortcuts

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