functions

package
v0.3.9 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Random = rand.New(rand.NewSource(0))

Functions

func Account

func Account(length int) string

Account returns a random account number of given length

func AddValueToList

func AddValueToList(l string, v string) string

AddValueToList adds value v to Context list l

func Amount

func Amount(min float32, max float32, currency string) string

Amount returns an amount of money between min and max, and given currency

func Atoi

func Atoi(s string) int

func BirthDate

func BirthDate(minAge int, maxAge int) string

BirthDate returns a birthdate between minAge and maxAge

func Bitcoin

func Bitcoin() string

Bitcoin returns a bitcoin address

func BuildingNumber

func BuildingNumber(n int) string

BuildingNumber generates a random building number of max n digits

func Cache

func Cache(name string) (bool, error)

Cache is used to internally Cache data from word files

func Capital

func Capital() string

Capital returns a random Capital

func CapitalAt

func CapitalAt(index int) string

CapitalAt returns Capital at given index

func Cardinal

func Cardinal(short bool) string

Cardinal return a random cardinal direction, in long or short form

func City

func City() string

City returns a random City

func CityAt

func CityAt(index int) string

CityAt returns City at given index

func CodiceFiscale

func CodiceFiscale() string

CodiceFiscale return a valid Italian Codice Fiscale

func Company

func Company() string

Company returns a random Company Name

func Contains

func Contains(s []string, str string) bool

Contains checks if the str string is present in an array of string []string

func Counter

func Counter(c string, start, step int) int

Counter creates a counter named c, starting from start and incrementing by step

func Country

func Country() string

Country returns the ISO 3166 Country selected with locale

func CountryAt

func CountryAt(index int) string

CountryAt returns an ISO 3166 Country at a given index

func CountryCode

func CountryCode() string

CountryCode returns a random Country Code prefix

func CountryCodeAt

func CountryCodeAt(index int) string

CountryCodeAt returns a Country Code prefix at a given index

func CountryRandom

func CountryRandom() string

CountryRandom returns a random ISO 3166 Country

func CreditCard

func CreditCard(issuer string) string

CreditCard returns a valid credit card

func CreditCardCVV

func CreditCardCVV(length int) string

CreditCardCVV returns a random credit card CVV of given length

func Cusip

func Cusip() string

Cusip returns a valid 9 characters Cusip code

func CusipCheckDigit

func CusipCheckDigit(code string) string

CusipCheckDigit calculates cusip check digit

func DateBetween

func DateBetween(fromDate string, toDate string) string

DateBetween returns a date between fromDate and toDate

func DatesBetween

func DatesBetween(fromDate string, toDate string, num int) []string

DatesBetween returns an array of num dates between fromDate and toDate

func DescriptionMap

func DescriptionMap() map[string]FunctionDescription

func Email

func Email() string

Email returns a random email.

func EmailProvider

func EmailProvider() string

EmailProvider returns a random email provider

func Ethereum

func Ethereum() string

Ethereum returns an ethereum address

func ExecuteTemplate

func ExecuteTemplate(key *template.Template, value *template.Template, oneline bool) (string, string, error)

func FromCsv

func FromCsv(c string) string

FromCsv gets the label value from csv file

func FunctionsMap

func FunctionsMap() template.FuncMap

func Future

func Future(years int) string

Future returns a date in the future not after the given years

func Gender

func Gender() string

Gender returns a random gender. Note: it gets the gender context automatically setup by previous name calls

func GetV

func GetV(s string) string

GetV gets value s from Context

func GetValueFromListAtIndex

func GetValueFromListAtIndex(s string, index int) string

GetValuesFromList returns a value from Context list l at index

func HttpMethod

func HttpMethod() string

HttpMethod returns a random http method

func Image

func Image(width int, height int) string

Image generates a random Image url of given width, height and type

func ImageOf

func ImageOf(width int, height int, imageType string) string

ImageOf generates a random Image url of given width, height and type

func Imei

func Imei() string

Imei returns a random imei number of 15 digits

func IndexOf

func IndexOf(s string, name string) int

IndexOf returns the index of the s string in a file

func InitCSV

func InitCSV(csvpath string)

func Inject

func Inject(probability float64, injected, original any) any

Inject is used to inject a different value with a given probability, typically used to generate a bad value

func Ip

func Ip(cidr string) string

Ip returns a random Ip Address matching the given cidr

func IpKnownPort

func IpKnownPort() string

IpKnownPort returns a random known port number

func IpKnownProtocol

func IpKnownProtocol() string

IpKnownProtocol returns a random known protocol

func Ipv6

func Ipv6() string

Ipv6 returns a random Ipv6 Address

func Isin

func Isin(country string) string

Isin returns a valid 12 characters Isin code

func IsinCheckDigit

func IsinCheckDigit(code string) string

IsinCheckDigit calculates an isin check digit

func Latitude

func Latitude() string

Latitude returns a random latitude between -90 and 90

func Len

func Len(name string) string

Len returns number of words (lines) in a word file

func Longitude

func Longitude() string

Longitude returns a random longitude between -180 and 180

func Lorem

func Lorem(size int) string

Lorem generates a 'lorem ipsum' text of size words

func LuhnCheckDigit

func LuhnCheckDigit(code string) string

LuhnCheckDigit calculates luhn check digit

func Mac

func Mac() string

Mac returns a random Mac Address

func Maxint

func Maxint(a, b int) int

Maxint returns the minimum between two ints

func Middlename

func Middlename() string

Middlename returns a random Middlename

func Minint

func Minint(a, b int) int

Minint returns the minimum between two ints

func MobilePhone

func MobilePhone() string

MobilePhone returns a random mobile phone

func MobilePhoneAt

func MobilePhoneAt(index int) string

MobilePhoneAt returns a mobile phone at a given index

func Name

func Name() string

Name returns a random Name (male/female)

func NameF

func NameF() string

NameF returns a random female Name

func NameM

func NameM() string

NameM returns a random male Name

func NearbyGPS

func NearbyGPS(latitude float64, longitude float64, radius int) string

NearbyGPS returns a random latitude longitude within a given radius in meters

func Nonsense

func Nonsense(prefixLen, numWords int, baseText string) string

Nonsense generates a random Sentence of numWords wordsm using a prefixLen and a baseText to start from

func Password

func Password(length int, memorable bool, prefix string, suffix string) string

Password returns a random Password of given length, memorable, and with prefix and suffix

func Past

func Past(years int) string

Past returns a date in the past not before the given years

func Phone

func Phone() string

Phone returns a random land prefix

func PhoneAt

func PhoneAt(index int) string

PhoneAt returns a land prefix at a given index

func RandomBool

func RandomBool() string

RandomBool returns a random boolean

func RandomIndex

func RandomIndex(name string) string

RandomIndex returns a random index in a word file

func RandomNValuesFromList

func RandomNValuesFromList(s string, n int) []string

RandomNValuesFromList returns a random value from Context list l

func RandomString

func RandomString(min, max int) string

RandomString returns a random string long between min and max characters

func RandomStringVocabulary

func RandomStringVocabulary(min, max int, source string) string

RandomStringVocabulary returns a random string long between min and max characters using a vocabulary

func RandomValueFromList

func RandomValueFromList(s string) string

RandomValueFromList returns a random value from Context list l

func Recent

func Recent(days int) string

Recent returns a date in the past not before the given days

func Regex

func Regex(regex string) (string, error)

Regex returns a random string matching the given Regex parameter

func Sedol

func Sedol() string

Sedol returns a valid 7 characters sedol code

func SedolCheckDigit

func SedolCheckDigit(code string) string

SedolCheckDigit calculates sedol check digit

func Seed

func Seed(rndSeed int64) string

Seed sets seeds and can be used in a template

func Sentence

func Sentence(numWords int) string

Sentence generates an 'alice in wonderland' text of size words

func SentencePrefix

func SentencePrefix(prefixLen, numWords int) string

SentencePrefix generates an 'alice in wonderland' text of size words with given prefixLen

func SetSeed

func SetSeed(rndSeed int64)

SetSeed sets seeds for all random JR objects

func SetV

func SetV(s string, v string) string

SetV adds value v to Context

func Soon

func Soon(days int) string

Soon returns a date in the future not after the given days

func Ssn

func Ssn() string

Ssn return a valid Social Security Number id

func State

func State() string

State returns a random State

func StateAt

func StateAt(index int) string

StateAt returns State at given index

func StateShort

func StateShort() string

StateShort returns a random short State

func StateShortAt

func StateShortAt(index int) string

StateShortAt returns short State at given index

func StockSymbol

func StockSymbol() string

StockSymbol returns a NASDAQ stock symbol

func Street

func Street() string

Street returns a random street

func Surname

func Surname() string

Surname returns a random Surname

func Swift

func Swift() string

Swift returns a swift/bic code

func UniqueId

func UniqueId() string

UniqueId returns a random uuid

func UnixTimeStamp

func UnixTimeStamp(days int) int64

UnixTimeStamp returns a random unix timestamp not older than the given number of days

func User

func User(firstName string, lastName string, size int) string

User returns a random Username using Name, Surname and a length

func UserAgent

func UserAgent() string

UserAgent returns a random user agent

func Username

func Username(firstName string, lastName string) string

Username returns a random Username using Name, Surname

func Valor

func Valor() string

Valor returns a valid 6-9 digits Valor code

func Wkn

func Wkn() string

Wkn returns a valid 6 characters wkn code

func Word

func Word(name string) string

Word returns a random string from a list of strings in a file.

func WordAt

func WordAt(name string, index int) string

WordAt returns a string at a given position in a list of strings in a file.

func WordShuffle

func WordShuffle(name string) []string

WordShuffle returns a shuffled list of strings in a file.

func WordShuffleN

func WordShuffleN(name string, n int) []string

wordShuffleN return a subset of n elements in a list of string in a file.

func WorkEmail

func WorkEmail() string

WorkEmail returns a random work email.

func YesOrNo

func YesOrNo() string

YesOrNo returns a random yes or no

func Zip

func Zip() string

Zip returns a random Zip code

func ZipAt

func ZipAt(index int) string

ZipAt returns Zip code at given index

Types

type Chain

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

Chain contains a map ("chain") of prefixes to a list of suffixes. A prefix is a string of prefixLen words joined with spaces. A suffix is a single word. A prefix can have multiple suffixes.

func NewChain

func NewChain(prefixLen int) *Chain

NewChain returns a new Chain with prefixes of prefixLen words.

func (*Chain) Build

func (c *Chain) Build(r io.Reader)

Build reads text from the provided Reader and parses it into prefixes and suffixes that are stored in Chain.

func (*Chain) Generate

func (c *Chain) Generate(n int) string

Generate returns a string of at most n words generated from Chain.

type FunctionDescription

type FunctionDescription struct {
	Name        string
	Category    string
	Description string
	Parameters  string
	Localizable bool
	Return      string
	Example     string
	Output      string
}

func Description

func Description(name string) (FunctionDescription, bool)

type Prefix

type Prefix []string

Prefix is a Markov chain prefix of one or more words.

func (Prefix) Shift

func (p Prefix) Shift(word string)

Shift removes the first word from the Prefix and appends the given word.

func (Prefix) String

func (p Prefix) String() string

String returns the Prefix as a string (for use as a map key).

Jump to

Keyboard shortcuts

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