tokens

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2023 License: Unlicense Imports: 10 Imported by: 2

Documentation

Index

Constants

View Source
const (
	TOKEN_START              = "["
	TOKEN_END                = "]"
	TOKEN_TYPE_STR           = "str"
	TOKEN_TYPE_STR_L         = TOKEN_TYPE_STR + ":"
	TOKEN_TYPE_STR_U         = TOKEN_TYPE_STR + "U:"
	TOKEN_TYPE_STR_R         = TOKEN_TYPE_STR + "R:"
	TOKEN_TYPE_ALPHA         = "mix"
	TOKEN_TYPE_ALPHA_L       = TOKEN_TYPE_ALPHA + ":"
	TOKEN_TYPE_ALPHA_U       = TOKEN_TYPE_ALPHA + "U:"
	TOKEN_TYPE_ALPHA_R       = TOKEN_TYPE_ALPHA + "R:"
	TOKEN_TYPE_INT           = "int:"
	TOKEN_TYPE_UUID          = "#UUID"
	TOKEN_TYPE_BASE64_ENCODE = "b64:"
	TOKEN_TYPE_URL_ENCODE    = "url:"
	TOKEN_TYPE_FROM_FILE     = ":"
)

Variables

View Source
var FilesCache *utils.FilesCache

Functions

This section is empty.

Types

type RandomStringGenerator

type RandomStringGenerator struct {
	DataDir string
}

func NewRandomStringGenerator

func NewRandomStringGenerator(dataDir string, fileCacheErrorHandler func(err error)) *RandomStringGenerator

func (*RandomStringGenerator) Generate

func (pp *RandomStringGenerator) Generate(str string) string

Generate takes the input string and replaces all tokens with randomly generated data. Tokens can be nested.

Available tokens:

[#UUID]   = random UUID (xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxx)
[#56]     = random 56-characters hash
[int:6]   = random 6-characters integer (zero-padded)
[str:6]   = random 6-characters lowercase string (a-z)
[strU:6]  = random 6-characters uppercase string (A-Z)
[strR:6]  = random 6-characters mixed-case string (a-z, A-Z)
[mix:6]   = random 6-characters lowercase alphanumeric string (a-z, 0-9)
[mixU:6]  = random 6-characters uppercase alphanumeric string (A-Z, 0-9)
[mixR:6]  = random 6-characters mixed-case alphanumeric string (a-z, A-Z, 0-9)
[10-500]  = random value between 10 and 500 (inclusive)
[10..500] = comma separated list with all ints from 10 to 500 (inclusive)
[a,b,c]   = random value from the list

[b64:data] = base64-encodes 'data'
[url:data] = url-encodes 'data'
[:path]    = reads a random line from the given "path" (if path is a directory a random file from that directory will be used)

type Token

type Token string

type TokenHash

type TokenHash struct {
	Length int
}

func (*TokenHash) Parse

func (t *TokenHash) Parse() string

type TokenInt

type TokenInt struct {
	Length int
}

func (*TokenInt) Parse

func (t *TokenInt) Parse() string

type TokenIntList

type TokenIntList struct {
	Min int
	Max int
}

func (*TokenIntList) Parse

func (t *TokenIntList) Parse() string

type TokenIntRange

type TokenIntRange struct {
	Min int
	Max int
}

func (*TokenIntRange) Parse

func (t *TokenIntRange) Parse() string

type TokenLineFromFile

type TokenLineFromFile struct {
	File string
}

func (*TokenLineFromFile) Parse

func (t *TokenLineFromFile) Parse(dataDir string) string

type TokenMix

type TokenMix struct {
	Length int
}

func (*TokenMix) Parse

func (t *TokenMix) Parse() string

type TokenMixLower

type TokenMixLower struct {
	Length int
}

func (*TokenMixLower) Parse

func (t *TokenMixLower) Parse() string

type TokenMixUpper

type TokenMixUpper struct {
	Length int
}

func (*TokenMixUpper) Parse

func (t *TokenMixUpper) Parse() string

type TokenRandomUUID

type TokenRandomUUID string

func (*TokenRandomUUID) Parse

func (vir *TokenRandomUUID) Parse() string

type TokenStr

type TokenStr struct {
	Length int
}

func (*TokenStr) Parse

func (t *TokenStr) Parse() string

type TokenStrFromList

type TokenStrFromList struct {
	Strings []string
}

func (*TokenStrFromList) Parse

func (t *TokenStrFromList) Parse() string

type TokenStrLower

type TokenStrLower struct {
	Length int
}

func (*TokenStrLower) Parse

func (t *TokenStrLower) Parse() string

type TokenStrUpper

type TokenStrUpper struct {
	Length int
}

func (*TokenStrUpper) Parse

func (t *TokenStrUpper) Parse() string

type Tokens

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

func (*Tokens) Append

func (ts *Tokens) Append(tokens ...string) *Tokens

func (*Tokens) FromFile

func (ts *Tokens) FromFile(file string) *Tokens

func (*Tokens) FromSlice

func (ts *Tokens) FromSlice(tokens []string) *Tokens

func (*Tokens) Length

func (ts *Tokens) Length() int

func (*Tokens) Random

func (ts *Tokens) Random() string

type UnknownToken

type UnknownToken string

Jump to

Keyboard shortcuts

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