Documentation ¶
Overview ¶
MIT License
Copyright (c) 2017 Iman Tumorang ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
MIT License ¶
Copyright (c) 2017 Iman Tumorang ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
MIT License ¶
Copyright (c) 2017 Iman Tumorang ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
MIT License ¶
Copyright (c) 2017 Iman Tumorang ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
MIT License ¶
Copyright (c) 2017 Iman Tumorang ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
MIT License ¶
Copyright (c) 2017 Iman Tumorang ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
MIT License ¶
Copyright (c) 2017 Iman Tumorang ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
MIT License ¶
Copyright (c) 2017 Iman Tumorang ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
MIT License ¶
Copyright (c) 2017 Iman Tumorang ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
MIT License ¶
Copyright (c) 2017 Iman Tumorang ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
MIT License ¶
Copyright (c) 2017 Iman Tumorang ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Index ¶
- Constants
- Variables
- func AddProvider(tag string, provider TaggedFunction) error
- func AmountWithCurrency() string
- func CCNumber() string
- func CCType() string
- func Century() string
- func ChineseFirstName() string
- func ChineseLastName() string
- func ChineseName() string
- func Contains(slice []string, item string) bool
- func ContainsRune(set map[rune]struct{}, item rune) bool
- func ContainsValue(slice []interface{}, value interface{}) bool
- func Currency() string
- func Date() string
- func DayOfMonth() string
- func DayOfWeek() string
- func DomainName() string
- func E164PhoneNumber() string
- func Email() string
- func FirstName() string
- func FirstNameFemale() string
- func FirstNameMale() string
- func Gender() string
- func GetValue(t reflect.Type, level int) (reflect.Value, error)
- func IPv4() string
- func IPv6() string
- func IntToString(intSl []int) (str []string)
- func IsExportByName(name string) bool
- func Jwt() string
- func LastName() string
- func Latitude() float64
- func Longitude() float64
- func MacAddress() string
- func MonthName() string
- func Name() string
- func NewSafeSource(in mathrand.Source) mathrand.Source
- func Paragraph() string
- func Password() string
- func Phonenumber() string
- func RandomInt(parameters ...int) (p []int, err error)
- func RandomUnixTime() int64
- func RemoveProvider(tag string) error
- func SafeSet(v reflect.Value, i int, level int, found bool, fake interface{})
- func Sentence() string
- func SetAddress(net Addresser)
- func SetCryptoSource(in io.Reader)
- func SetDataFaker(d DataFaker)
- func SetDateTimer(d DateTimer)
- func SetDowser(d Dowser)
- func SetNetwork(net Networker)
- func SetPayment(p Render)
- func SetPhoner(p Phoner)
- func SetPrice(p Money)
- func SetRandomSource(in mathrand.Source)
- func TimeString() string
- func Timeperiod() string
- func Timestamp() string
- func Timezone() string
- func TitleFemale() string
- func TitleMale() string
- func TollFreePhoneNumber() string
- func URL() string
- func UUIDDigit() string
- func UUIDHyphenated() string
- func UnixTime() int64
- func Username() string
- func Word() string
- func YearString() string
- type Address
- type Addresser
- type DataFaker
- type DateTime
- func (d DateTime) Century(v reflect.Value) (interface{}, error)
- func (d DateTime) Date(v reflect.Value) (interface{}, error)
- func (d DateTime) DayOfMonth(v reflect.Value) (interface{}, error)
- func (d DateTime) DayOfWeek(v reflect.Value) (interface{}, error)
- func (d DateTime) MonthName(v reflect.Value) (interface{}, error)
- func (d DateTime) Time(v reflect.Value) (interface{}, error)
- func (d DateTime) TimePeriod(v reflect.Value) (interface{}, error)
- func (d DateTime) TimeZone(v reflect.Value) (interface{}, error)
- func (d DateTime) Timestamp(v reflect.Value) (interface{}, error)
- func (d DateTime) UnixTime(v reflect.Value) (interface{}, error)
- func (d DateTime) Year(v reflect.Value) (interface{}, error)
- type DateTimer
- type Dowser
- type Identifier
- type Internet
- func (internet Internet) DomainName(v reflect.Value) (interface{}, error)
- func (internet Internet) Email(v reflect.Value) (interface{}, error)
- func (internet Internet) IPv4(v reflect.Value) (interface{}, error)
- func (internet Internet) IPv6(v reflect.Value) (interface{}, error)
- func (internet Internet) Jwt(v reflect.Value) (interface{}, error)
- func (internet Internet) MacAddress(v reflect.Value) (interface{}, error)
- func (internet Internet) Password(v reflect.Value) (interface{}, error)
- func (internet Internet) URL(v reflect.Value) (interface{}, error)
- func (internet Internet) UserName(v reflect.Value) (interface{}, error)
- type Lorem
- type Money
- type Networker
- type Payment
- type Person
- func (p Person) ChineseFirstName(v reflect.Value) (interface{}, error)
- func (p Person) ChineseLastName(v reflect.Value) (interface{}, error)
- func (p Person) ChineseName(v reflect.Value) (interface{}, error)
- func (p Person) FirstName(v reflect.Value) (interface{}, error)
- func (p Person) FirstNameFemale(v reflect.Value) (interface{}, error)
- func (p Person) FirstNameMale(v reflect.Value) (interface{}, error)
- func (p Person) Gender(v reflect.Value) (interface{}, error)
- func (p Person) LastName(v reflect.Value) (interface{}, error)
- func (p Person) Name(v reflect.Value) (interface{}, error)
- func (p Person) TitleFeMale(v reflect.Value) (interface{}, error)
- func (p Person) TitleMale(v reflect.Value) (interface{}, error)
- type Phone
- type Phoner
- type Price
- type Render
- type TaggedFunction
- type UUID
Constants ¶
const ( BaseDateFormat = "2006-01-02" TimeFormat = "15:04:05" MonthFormat = "January" YearFormat = "2006" DayFormat = "Monday" DayOfMonthFormat = "_2" TimePeriodFormat = "PM" )
These example values must use the reference time "Mon Jan 2 15:04:05 MST 2006" as described at https://gobyexample.com/time-formatting-parsing
const ( ID = "uuid_digit" HyphenatedID = "uuid_hyphenated" EmailTag = "email" MacAddressTag = "mac_address" DomainNameTag = "domain_name" UserNameTag = "username" URLTag = "url" IPV4Tag = "ipv4" IPV6Tag = "ipv6" PASSWORD = "password" JWT = "jwt" LATITUDE = "lat" LONGITUDE = "long" CreditCardNumber = "cc_number" CreditCardType = "cc_type" PhoneNumber = "phone_number" TollFreeNumber = "toll_free_number" E164PhoneNumberTag = "e_164_phone_number" TitleMaleTag = "title_male" TitleFemaleTag = "title_female" FirstNameTag = "first_name" FirstNameMaleTag = "first_name_male" FirstNameFemaleTag = "first_name_female" LastNameTag = "last_name" NAME = "name" ChineseFirstNameTag = "chinese_first_name" ChineseLastNameTag = "chinese_last_name" ChineseNameTag = "chinese_name" GENDER = "gender" UnixTimeTag = "unix_time" DATE = "date" TIME = "time" MonthNameTag = "month_name" YEAR = "year" DayOfWeekTag = "day_of_week" DayOfMonthTag = "day_of_month" TIMESTAMP = "timestamp" CENTURY = "century" TIMEZONE = "timezone" TimePeriodTag = "time_period" WORD = "word" SENTENCE = "sentence" PARAGRAPH = "paragraph" CurrencyTag = "currency" AmountTag = "amount" AmountWithCurrencyTag = "amount_with_currency" SKIP = "-" Length = "len" SliceLength = "slice_len" Language = "lang" BoundaryStart = "boundary_start" BoundaryEnd = "boundary_end" Equals = "=" ONEOF = "oneof" )
Supported tags
Variables ¶
var ( // LangENG is for english language LangENG = langRuneBoundary{65, 122, []rune{91, 92, 93, 94, 95, 96}} // LangCHI is for chinese language LangCHI = langRuneBoundary{19968, 40869, nil} // LangRUS is for russian language LangRUS = langRuneBoundary{1025, 1105, nil} )
Language rune boundaries here
var ( ErrUnsupportedKindPtr = "Unsupported kind: %s Change Without using * (pointer) in Field of %s" ErrUnsupportedKind = "Unsupported kind: %s" ErrValueNotPtr = "Not a pointer value" ErrTagNotSupported = "Tag unsupported: %s" ErrTagAlreadyExists = "Tag exists" ErrTagDoesNotExist = "Tag does not exist" ErrMoreArguments = "Passed more arguments than is possible : (%d)" ErrNotSupportedPointer = "Use sample:=new(%s)\n faker.FakeData(sample) instead" ErrSmallerThanZero = "Size:%d is smaller than zero." ErrSmallerThanOne = "Size:%d is smaller than one." ErrUniqueFailure = "Failed to generate a unique value for field \"%s\"" ErrStartValueBiggerThanEnd = "Start value can not be bigger than end value." ErrWrongFormattedTag = "Tag \"%s\" is not written properly" ErrUnknownType = "Unknown Type" ErrNotSupportedTypeForTag = "Type is not supported by tag." ErrUnsupportedTagArguments = "Tag arguments are not compatible with field type." ErrDuplicateSeparator = "Duplicate separator for tag arguments." ErrNotEnoughTagArguments = "Not enough arguments for tag." ErrUnsupportedNumberType = "Unsupported Number type." )
Generic Error Messages for tags
ErrUnsupportedKindPtr: Error when get fake from ptr ErrUnsupportedKind: Error on passing unsupported kind ErrValueNotPtr: Error when value is not pointer ErrTagNotSupported: Error when tag is not supported ErrTagAlreadyExists: Error when tag exists and call AddProvider ErrTagDoesNotExist: Error when tag does not exist and call RemoveProvider ErrMoreArguments: Error on passing more arguments ErrNotSupportedPointer: Error when passing unsupported pointer
var MapperTag = mapperTag
var PriorityTags = []string{ID, HyphenatedID, EmailTag, MacAddressTag, DomainNameTag, UserNameTag, URLTag, IPV4Tag, IPV6Tag, PASSWORD, JWT, LATITUDE, LONGITUDE, CreditCardNumber, CreditCardType, PhoneNumber, TollFreeNumber, E164PhoneNumberTag, TitleMaleTag, TitleFemaleTag, FirstNameTag, FirstNameMaleTag, FirstNameFemaleTag, LastNameTag, NAME, ChineseFirstNameTag, ChineseLastNameTag, ChineseNameTag, GENDER, UnixTimeTag, DATE, TIME, MonthNameTag, YEAR, DayOfWeekTag, DayOfMonthTag, TIMESTAMP, CENTURY, TIMEZONE, TimePeriodTag, WORD, SENTENCE, PARAGRAPH, CurrencyTag, AmountTag, AmountWithCurrencyTag, SKIP, Length, SliceLength, Language, BoundaryStart, BoundaryEnd, ONEOF, }
PriorityTags define the priority order of the tag
Functions ¶
func AddProvider ¶
func AddProvider(tag string, provider TaggedFunction) error
AddProvider extend faker with tag to generate fake data with specified custom algorithm Example:
type Gondoruwo struct { Name string Locatadata int } type Sample struct { ID int64 `faker:"customIdFaker"` Gondoruwo Gondoruwo `faker:"gondoruwo"` Danger string `faker:"danger"` } func CustomGenerator() { // explicit faker.AddProvider("customIdFaker", func(v reflect.Value) (interface{}, error) { return int64(43), nil }) // functional faker.AddProvider("danger", func() faker.TaggedFunction { return func(v reflect.Value) (interface{}, error) { return "danger-ranger", nil } }()) faker.AddProvider("gondoruwo", func(v reflect.Value) (interface{}, error) { obj := Gondoruwo{ Name: "Power", Locatadata: 324, } return obj, nil }) } func main() { CustomGenerator() var sample Sample faker.FakeData(&sample) fmt.Printf("%+v", sample) }
Will print
{ID:43 Gondoruwo:{Name:Power Locatadata:324} Danger:danger-ranger}
Notes: when using a custom provider make sure to return the same type as the field
func AmountWithCurrency ¶
func AmountWithCurrency() string
AmountWithCurrency get fake AmountWithCurrency USD 49257.100
func CCNumber ¶
func CCNumber() string
CCNumber get a credit card number randomly in string (VISA, MasterCard, etc)
func CCType ¶
func CCType() string
CCType get a credit card type randomly in string (VISA, MasterCard, etc)
func ContainsRune ¶
ContainsRune Check item in map rune type
func ContainsValue ¶
func ContainsValue(slice []interface{}, value interface{}) bool
ContainsValue check if value exists in slice, no matter its type
func IntToString ¶
IntToString Convert slice int to slice string
func IsExportByName ¶
func NewSafeSource ¶
NewSafeSource wraps an unsafe rand.Source with a mutex to guard the random source against concurrent access.
func RandomInt ¶
RandomInt Get three parameters , only first mandatory and the rest are optional
If only set one parameter : This means the minimum number of digits and the total number If only set two parameters : First this is min digit and second max digit and the total number the difference between them If only three parameters: the third argument set Max count Digit
func RandomUnixTime ¶
func RandomUnixTime() int64
RandomUnixTime is a helper function returning random Unix time
func RemoveProvider ¶
RemoveProvider removes existing customization added with AddProvider
func SetCryptoSource ¶
SetCryptoSource sets a new reader for functions using a cryptographically-safe random generator (e.g. UUID).
The default is the global source provided by crypto/rand.
func SetRandomSource ¶
SetRandomSource sets a new random source at the package level.
To use a concurrent-safe source, you may wrap it with NewSafeSource, e.g. SetRandomSource(NewSafeSource(mysource)).
The default is the global, concurrent-safe source provided by math/rand.
func Timestamp ¶
func Timestamp() string
Timestamp get timestamp randomly in string format: 2006-01-02 15:04:05
func TitleFemale ¶
func TitleFemale() string
TitleFemale get a title female randomly in string ("Mrs.", "Ms.", "Miss", "Dr.", "Prof.", "Lady", "Queen", "Princess")
func TitleMale ¶
func TitleMale() string
TitleMale get a title male randomly in string ("Mr.", "Dr.", "Prof.", "Lord", "King", "Prince")
func TollFreePhoneNumber ¶
func TollFreePhoneNumber() string
TollFreePhoneNumber get fake TollFreePhoneNumber
Types ¶
type Address ¶
type Address struct{}
Address struct
type Addresser ¶
type Addresser interface { Latitude(v reflect.Value) (interface{}, error) Longitude(v reflect.Value) (interface{}, error) }
Addresser is logical layer for Address
func GetAddress ¶
func GetAddress() Addresser
GetAddress returns a new Addresser interface of Address
type DataFaker ¶
type DataFaker interface { Word(v reflect.Value) (interface{}, error) Sentence(v reflect.Value) (interface{}, error) Paragraph(v reflect.Value) (interface{}, error) }
DataFaker generates randomized Words, Sentences and Paragraphs
type DateTime ¶
type DateTime struct { }
DateTime struct
func (DateTime) DayOfMonth ¶
DayOfMonth formats DateTime using example DayOfMonth const
func (DateTime) TimePeriod ¶
TimePeriod formats DateTime using example TimePeriod const
type DateTimer ¶
type DateTimer interface { UnixTime(v reflect.Value) (interface{}, error) Date(v reflect.Value) (interface{}, error) Time(v reflect.Value) (interface{}, error) MonthName(v reflect.Value) (interface{}, error) Year(v reflect.Value) (interface{}, error) DayOfWeek(v reflect.Value) (interface{}, error) DayOfMonth(v reflect.Value) (interface{}, error) Timestamp(v reflect.Value) (interface{}, error) Century(v reflect.Value) (interface{}, error) TimeZone(v reflect.Value) (interface{}, error) TimePeriod(v reflect.Value) (interface{}, error) }
A DateTimer contains random Time generators, returning time string in certain particular format
func GetDateTimer ¶
func GetDateTimer() DateTimer
GetDateTimer returns a new DateTimer interface of DateTime
type Dowser ¶
type Dowser interface { TitleMale(v reflect.Value) (interface{}, error) TitleFeMale(v reflect.Value) (interface{}, error) FirstName(v reflect.Value) (interface{}, error) FirstNameMale(v reflect.Value) (interface{}, error) FirstNameFemale(v reflect.Value) (interface{}, error) LastName(v reflect.Value) (interface{}, error) Name(v reflect.Value) (interface{}, error) Gender(v reflect.Value) (interface{}, error) ChineseFirstName(v reflect.Value) (interface{}, error) ChineseLastName(v reflect.Value) (interface{}, error) ChineseName(v reflect.Value) (interface{}, error) }
Dowser provides interfaces to generate random logical Names with their initials
type Identifier ¶
type Identifier interface { Digit(v reflect.Value) (interface{}, error) Hyphenated(v reflect.Value) (interface{}, error) }
Identifier ...
type Internet ¶
type Internet struct{}
Internet struct
func (Internet) DomainName ¶
DomainName generates random domain name
func (Internet) MacAddress ¶
MacAddress generates random MacAddress
type Lorem ¶
type Lorem struct { }
Lorem struct
func (Lorem) Paragraph ¶
Paragraph returns a series of sentences as a paragraph using the wordList const
type Money ¶
type Money interface { Currency(v reflect.Value) (interface{}, error) Amount(v reflect.Value) (interface{}, error) AmountWithCurrency(v reflect.Value) (interface{}, error) }
Money provides an interface to generate a custom price with or without a random currency code
type Networker ¶
type Networker interface { Email(v reflect.Value) (interface{}, error) MacAddress(v reflect.Value) (interface{}, error) DomainName(v reflect.Value) (interface{}, error) URL(v reflect.Value) (interface{}, error) UserName(v reflect.Value) (interface{}, error) IPv4(v reflect.Value) (interface{}, error) IPv6(v reflect.Value) (interface{}, error) Password(v reflect.Value) (interface{}, error) Jwt(v reflect.Value) (interface{}, error) }
Networker is logical layer for Internet
func GetNetworker ¶
func GetNetworker() Networker
GetNetworker returns a new Networker interface of Internet
type Payment ¶
type Payment struct{}
Payment struct
func (Payment) CreditCardNumber ¶
CreditCardNumber generated credit card number according to the card number rules
type Person ¶
type Person struct { }
Person struct
func (Person) ChineseFirstName ¶
ChineseFirstName returns a random chinese first name
func (Person) ChineseLastName ¶
ChineseLastName returns a random chinese last name
func (Person) ChineseName ¶
ChineseName returns a random nhinese name
func (Person) FirstNameFemale ¶
FirstNameFemale returns first names for females
func (Person) FirstNameMale ¶
FirstNameMale returns first names for males
func (Person) TitleFeMale ¶
TitleFeMale generates random titles for females
type Phone ¶
type Phone struct { }
Phone struct
func (Phone) E164PhoneNumber ¶
E164PhoneNumber generates phone numbers of type: "+27113456789"
func (Phone) PhoneNumber ¶
PhoneNumber generates phone numbers of type: "201-886-0269"
type Phoner ¶
type Phoner interface { PhoneNumber(v reflect.Value) (interface{}, error) TollFreePhoneNumber(v reflect.Value) (interface{}, error) E164PhoneNumber(v reflect.Value) (interface{}, error) }
Phoner serves overall tele-phonic contact generator
type Price ¶
type Price struct { }
Price struct
func (Price) Amount ¶
Amount returns a random floating price amount with a random precision of [1,2] up to (10**8 - 1)
func (Price) AmountWithCurrency ¶
AmountWithCurrency combines both price and currency together
type Render ¶
type Render interface { CreditCardType(v reflect.Value) (interface{}, error) CreditCardNumber(v reflect.Value) (interface{}, error) }
Render contains Whole Random Credit Card Generators with their types
func GetPayment ¶
func GetPayment() Render
GetPayment returns a new Render interface of Payment struct
type TaggedFunction ¶
TaggedFunction used as the standard layout function for tag providers in struct. This type also can be used for custom provider.