replacer

package
v1.0.0-alpha3 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2018 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IPV4           = "ipv4"
	IPV4CHINA      = "ipv4China"
	CELLPHONECHINA = "cellphoneChina"
	IPV6           = "ipv6"
	MAC            = "mac"
	UA             = "userAgent"
	COUNTRY        = "country"
	EMAIL          = "email"
	NAME           = "name"
	CHINESENAME    = "chineseName"
	UUID           = "uuid"
	XML            = "xml"
	JSON           = "json"
)

LooksReal data methods

View Source
const (
	NEXT   = "next"
	PREV   = "prev"
	RANDOM = "random"
)

Value selection method

View Source
const (
	MAXDEPTH    = "maxDepth"
	MAXELEMENTS = "maxElements"
	TAGSEED     = "tagSeed"
)

Looks-real opts

Variables

This section is empty.

Functions

func Build

func Build(replace []byte) (map[string]Replacer, error)

Build builds and returns an string-Replacer map for future use.

func GetRandomChinaCellPhoneNo

func GetRandomChinaCellPhoneNo(g *rng.GaussianGenerator) string

GetRandomChinaCellPhoneNo returns a random cell phone number starts with 130 - 139

func GetRandomChinaIP

func GetRandomChinaIP(g *rng.GaussianGenerator) string

GetRandomChinaIP returns a random IP address of China.

func GetRandomChineseName

func GetRandomChineseName(g *rng.GaussianGenerator) string

GetRandomChineseName generates random (in gaussian distribution) Chinese name picked from the seed.

func GetRandomString

func GetRandomString(chars string, length int) string

GetRandomString generates a random string of length n.

func GetRandomUUID

func GetRandomUUID() string

GetRandomUUID returns a random UUID V4.

func InitLooksRealParms

func InitLooksRealParms(parms map[string]interface{}, t string)

InitLooksRealParms initiate the parameters map with the default values

func RandomJSON

func RandomJSON(maxDepth int, maxElements int, seed []string) string

RandomJSON returns a randomly generated JSON doc in string format.

func RandomXML

func RandomXML(maxDepth int, maxElements int, seed []string) string

GetXMLStr returns a randomly generated XML doc in string format

func SimpleGaussian

func SimpleGaussian(g *rng.GaussianGenerator, gap int) int

SimpleGaussian returns a random value of Gaussian distribution. mean=0.5*the_range, stddev=0.2*the_range

Types

type FixedListReplacer

type FixedListReplacer struct {
	// contains filtered or unexported fields
}

FixedListReplacer is a struct to record config opts of a fixed-list replacement type.

func (*FixedListReplacer) ReplacedValue

func (fl *FixedListReplacer) ReplacedValue(g *rng.GaussianGenerator) (string, error)

ReplacedValue returns a new replacement value of fixed-list type.

type FloatReplacer

type FloatReplacer struct {
	// contains filtered or unexported fields
}

func (*FloatReplacer) ReplacedValue

func (f *FloatReplacer) ReplacedValue(g *rng.GaussianGenerator) (string, error)

type IntegerReplacer

type IntegerReplacer struct {
	// contains filtered or unexported fields
}

func (*IntegerReplacer) ReplacedValue

func (i *IntegerReplacer) ReplacedValue(g *rng.GaussianGenerator) (string, error)

ReplacedValue is the main function to populate replacement value of an integer type.

type LooksReal

type LooksReal struct {
	// contains filtered or unexported fields
}

LooksReal is a struct to record the configured method to generate data.

func (*LooksReal) ReplacedValue

func (ia *LooksReal) ReplacedValue(g *rng.GaussianGenerator) (data string, err error)

ReplacedValue returns random data based on the data type selection.

type Replacer

type Replacer interface {
	// ReplacedValue returns the new replaced value.
	ReplacedValue(*rng.GaussianGenerator) (string, error)
}

Replacer is the interface which must be implemented by a particular replacement policy.

func NewFixedListReplacer

func NewFixedListReplacer(c string, v []string, ci int) Replacer

NewFixedListReplacer returns a new FixedListReplacer struct instance

func NewFloatReplacer

func NewFloatReplacer(min float64, max float64, precision int64) Replacer

func NewIntegerReplacer

func NewIntegerReplacer(c string, minV int64, maxV int64, cv int64) Replacer

NewIntegerReplacer returns a new IntegerReplacer struct instance

func NewLooksReal

func NewLooksReal(m string, p map[string]interface{}) Replacer

NewLooksReal returns a new LooksReal struct instance

func NewStringReplacer

func NewStringReplacer(chars string, min int64, max int64) Replacer

func NewTimeStampReplacer

func NewTimeStampReplacer(f string) Replacer

NewTimeStampReplacer returns a new TimeStampReplacer struct instance.

type StringReplacer

type StringReplacer struct {
	// contains filtered or unexported fields
}

func (*StringReplacer) ReplacedValue

func (s *StringReplacer) ReplacedValue(g *rng.GaussianGenerator) (string, error)

type TimeStampReplacer

type TimeStampReplacer struct {
	// contains filtered or unexported fields
}

func (*TimeStampReplacer) ReplacedValue

func (ts *TimeStampReplacer) ReplacedValue(*rng.GaussianGenerator) (string, error)

ReplacedValue populates a new timestamp with current time.

Jump to

Keyboard shortcuts

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