Documentation ¶
Index ¶
- func RandomElement[T any](f Faker, elements ...T) T
- func RandomElementWeighted[T any](f Faker, elements map[int]T) T
- type Address
- func (a Address) Address() string
- func (a Address) BuildingNumber() (bn string)
- func (a Address) City() string
- func (a Address) CityPrefix() string
- func (a Address) CitySuffix() string
- func (a Address) Country() string
- func (a Address) CountryAbbr() string
- func (a Address) CountryCode() string
- func (a Address) Latitude() (latitude float64)
- func (a Address) Longitude() (longitude float64)
- func (a Address) PostCode() string
- func (a Address) SecondaryAddress() string
- func (a Address) State() string
- func (a Address) StateAbbr() string
- func (a Address) StreetAddress() string
- func (a Address) StreetName() string
- func (a Address) StreetSuffix() string
- type App
- type Beer
- type BinaryString
- type Blood
- type Boolean
- type Car
- type Color
- type Company
- type ContactInfo
- type Crypto
- func (c Crypto) Bech32Address() string
- func (c Crypto) Bech32AddressWithLength(length int) string
- func (c Crypto) BitcoinAddress() string
- func (c Crypto) EtheriumAddress() string
- func (c Crypto) P2PKHAddress() string
- func (c Crypto) P2PKHAddressWithLength(length int) string
- func (c Crypto) P2SHAddress() string
- func (c Crypto) P2SHAddressWithLength(length int) string
- type Currency
- type Directory
- type Emoji
- type Faker
- func (f Faker) Address() Address
- func (f Faker) App() App
- func (f Faker) Asciify(in string) (out string)
- func (f Faker) Beer() Beer
- func (f Faker) BinaryString() BinaryString
- func (f Faker) Blood() Blood
- func (f Faker) Bool() bool
- func (f Faker) BoolWithChance(chanceTrue int) bool
- func (f Faker) Boolean() Boolean
- func (f Faker) Bothify(in string) (out string)
- func (f Faker) Car() Car
- func (f Faker) Color() Color
- func (f Faker) Company() Company
- func (f Faker) Crypto() Crypto
- func (f Faker) Currency() Currency
- func (f Faker) Directory() Directory
- func (f Faker) Emoji() Emoji
- func (f Faker) File() File
- func (f Faker) Float(maxDecimals, min, max int) float64
- func (f Faker) Float32(maxDecimals, min, max int) float32
- func (f Faker) Float64(maxDecimals, min, max int) float64
- func (f Faker) Food() Food
- func (f Faker) Gamer() Gamer
- func (f Faker) Gender() Gender
- func (f Faker) Genre() Genre
- func (f Faker) Hash() Hash
- func (f Faker) Image() Image
- func (f Faker) Int() int
- func (f Faker) Int16() int16
- func (f Faker) Int16Between(min, max int16) int16
- func (f Faker) Int32() int32
- func (f Faker) Int32Between(min, max int32) int32
- func (f Faker) Int64() int64
- func (f Faker) Int64Between(min, max int64) int64
- func (f Faker) Int8() int8
- func (f Faker) Int8Between(min, max int8) int8
- func (f Faker) IntBetween(min, max int) int
- func (f Faker) Internet() Internet
- func (f Faker) Json() Json
- func (f Faker) Language() Language
- func (f Faker) Letter() string
- func (f Faker) Lexify(in string) (out string)
- func (f Faker) Lorem() Lorem
- func (f Faker) LoremFlickr() LoremFlickr
- func (f Faker) Map() map[string]interface{}
- func (f Faker) MimeType() MimeType
- func (f Faker) Music() Music
- func (f Faker) Numerify(in string) (out string)
- func (f Faker) Payment() Payment
- func (f Faker) Person() Person
- func (f Faker) Pet() Pet
- func (f Faker) Phone() Phone
- func (f Faker) ProfileImage() ProfileImage
- func (f Faker) RandomDigit() int
- func (f Faker) RandomDigitNot(ignore ...int) int
- func (f Faker) RandomDigitNotNull() int
- func (f Faker) RandomFloat(maxDecimals, min, max int) float64
- func (f Faker) RandomIntElement(a []int) int
- func (f Faker) RandomLetter() string
- func (f Faker) RandomNumber(size int) int
- func (f Faker) RandomStringElement(s []string) string
- func (f Faker) RandomStringMapKey(m map[string]string) string
- func (f Faker) RandomStringMapValue(m map[string]string) string
- func (f Faker) RandomStringWithLength(l int) string
- func (Faker) ShuffleString(s string) string
- func (f Faker) Struct() Struct
- func (f Faker) Time() Time
- func (f Faker) UInt() uint
- func (f Faker) UInt16() uint16
- func (f Faker) UInt16Between(min, max uint16) uint16
- func (f Faker) UInt32() uint32
- func (f Faker) UInt32Between(min, max uint32) uint32
- func (f Faker) UInt64() uint64
- func (f Faker) UInt64Between(min, max uint64) uint64
- func (f Faker) UInt8() uint8
- func (f Faker) UInt8Between(min, max uint8) uint8
- func (f Faker) UIntBetween(min, max uint) uint
- func (f Faker) UUID() UUID
- func (f Faker) UserAgent() UserAgent
- func (f Faker) YouTube() YouTube
- type File
- type Food
- type Gamer
- type Gender
- type GeneratorInterface
- type Genre
- type HTTPClient
- type HTTPClientImpl
- type Hash
- type Image
- type Internet
- func (i Internet) CompanyEmail() string
- func (i Internet) Domain() string
- func (i Internet) Email() string
- func (i Internet) FreeEmail() string
- func (i Internet) FreeEmailDomain() string
- func (i Internet) HTTPMethod() string
- func (i Internet) Ipv4() string
- func (i Internet) Ipv6() string
- func (i Internet) LocalIpv4() string
- func (i Internet) MacAddress() string
- func (i Internet) Password() string
- func (i Internet) Query() string
- func (i Internet) SafeEmail() string
- func (Internet) SafeEmailDomain() string
- func (i Internet) Slug() string
- func (i Internet) StatusCode() int
- func (i Internet) StatusCodeMessage() string
- func (i Internet) StatusCodeWithMessage() string
- func (i Internet) TLD() string
- func (i Internet) URL() string
- func (i Internet) User() string
- type Json
- type Language
- type Lorem
- func (l Lorem) Bytes(maxNbChars int) (out []byte)
- func (l Lorem) Paragraph(nbSentences int) string
- func (l Lorem) Paragraphs(nbParagraph int) []string
- func (l Lorem) Sentence(nbWords int) string
- func (l Lorem) Sentences(nbSentences int) []string
- func (Lorem) Text(maxNbChars int) (out string)
- func (l Lorem) Word() string
- func (l Lorem) Words(nbWords int) []string
- type LoremFlickr
- type MimeType
- type Music
- type OSResolver
- type OSResolverImpl
- type Payment
- type Person
- func (p Person) Contact() ContactInfo
- func (p Person) FirstName() string
- func (p Person) FirstNameFemale() string
- func (p Person) FirstNameMale() string
- func (p Person) Gender() string
- func (Person) GenderFemale() string
- func (Person) GenderMale() string
- func (p Person) Image() *os.File
- func (p Person) LastName() string
- func (p Person) Name() string
- func (p Person) NameAndGender() (string, string)
- func (p Person) NameFemale() string
- func (p Person) NameMale() string
- func (p Person) SSN() string
- func (p Person) Suffix() string
- func (p Person) Title() string
- func (Person) TitleFemale() string
- func (Person) TitleMale() string
- type Pet
- type Phone
- type PngEncoder
- type PngEncoderImpl
- type ProfileImage
- type Struct
- type TempFileCreator
- type TempFileCreatorImpl
- type Time
- func (t Time) ANSIC(max time.Time) string
- func (t Time) AmPm() string
- func (t Time) Century() string
- func (t Time) DayOfMonth() int
- func (t Time) DayOfWeek() time.Weekday
- func (t Time) ISO8601(max time.Time) string
- func (t Time) Kitchen(max time.Time) string
- func (t Time) Month() time.Month
- func (t Time) MonthName() string
- func (t Time) RFC1123(max time.Time) string
- func (t Time) RFC1123Z(max time.Time) string
- func (t Time) RFC3339(max time.Time) string
- func (t Time) RFC3339Nano(max time.Time) string
- func (t Time) RFC822(max time.Time) string
- func (t Time) RFC822Z(max time.Time) string
- func (t Time) RFC850(max time.Time) string
- func (t Time) RubyDate(max time.Time) string
- func (t Time) Time(max time.Time) time.Time
- func (t Time) TimeBetween(min, max time.Time) time.Time
- func (t Time) Timezone() string
- func (t Time) Unix(max time.Time) int64
- func (t Time) UnixDate(max time.Time) string
- func (t Time) Year() int
- type UUID
- type UserAgent
- type YouTube
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RandomElement ¶ added in v2.2.0
RandomElement returns a fake random element from a given list of elements
func RandomElementWeighted ¶ added in v2.2.0
RandomElementWeighted takes faker instance and a list of elements in the form of map[weight]element, it then selects one of the elements randomly and returns it,
Elements with higher weight have more chance to be returned.
Types ¶
type Address ¶
type Address struct {
Faker *Faker
}
Address is a faker struct for Address
func (Address) BuildingNumber ¶
BuildingNumber returns a fake building number for Address
func (Address) CityPrefix ¶
CityPrefix returns a fake city prefix for Address
func (Address) CitySuffix ¶
CitySuffix returns a fake city suffix for Address
func (Address) CountryAbbr ¶
CountryAbbr returns a fake country abbreviation for Address
func (Address) CountryCode ¶
CountryCode returns a fake country code for Address
func (Address) SecondaryAddress ¶
SecondaryAddress returns a fake secondary address for Address
func (Address) StreetAddress ¶
StreetAddress returns a fake street address for Address
func (Address) StreetName ¶
StreetName returns a fake street name for Address
func (Address) StreetSuffix ¶
StreetSuffix returns a fake street suffix for Address
type Beer ¶
type Beer struct {
Faker *Faker
}
Beer is a faker struct for Beer
type BinaryString ¶
type BinaryString struct {
// contains filtered or unexported fields
}
BinaryString is the faker struct for BinaryString
func (BinaryString) BinaryString ¶
func (bn BinaryString) BinaryString(length int) string
BinaryString returns a random binarystring of given input length
type Boolean ¶
type Boolean struct {
Faker *Faker
}
Boolean is a faker struct for Boolean
func (Boolean) BoolString ¶
BoolString returns a fake bool for string Boolean
func (Boolean) BoolWithChance ¶
BoolWithChance returns true with a given percentual chance that the value is true, otherwise returns false
type Car ¶
type Car struct {
Faker *Faker
}
Car is a faker struct for Car
func (Car) TransmissionGear ¶
TransmissionGear will return a random car transmission gear
type Color ¶
type Color struct {
Faker *Faker
}
Color is a faker struct for Color
func (Color) RGBAsArray ¶
RGBAsArray returns a fake rgb color in array format for Color
func (Color) SafeColorName ¶
SafeColorName returns a fake safe color name for Color
type Company ¶
type Company struct {
Faker *Faker
}
Company is a faker struct for Company
func (Company) CatchPhrase ¶
CatchPhrase returns a fake catch phrase for Company
type ContactInfo ¶
ContactInfo struct full of contact info
type Crypto ¶
type Crypto struct {
Faker *Faker
}
Crypto is a faker struct for generating bitcoin data
func (Crypto) Bech32Address ¶
Bech32Address generates a Bech32 bitcoin address Deprecated: Please use BitcoinAddress instead.
func (Crypto) Bech32AddressWithLength ¶
Bech32AddressWithLength generates a Bech32 bitcoin address with specified length. Deprecated: Please use BitcoinAddress instead.
func (Crypto) BitcoinAddress ¶
BitcoinAddress returns an address of either Bech32, P2PKH, or P2SH type.
func (Crypto) EtheriumAddress ¶
EtheriumAddress returns a hexadecimal ethereum address of 42 characters.
func (Crypto) P2PKHAddress ¶
P2PKHAddress generates a P2PKH bitcoin address. Deprecated: Please use BitcoinAddress instead.
func (Crypto) P2PKHAddressWithLength ¶
P2PKHAddressWithLength generates a P2PKH bitcoin address with specified length. Deprecated: Please use BitcoinAddress instead.
func (Crypto) P2SHAddress ¶
P2SHAddress generates a P2SH bitcoin address. Deprecated: Please use BitcoinAddress instead.
func (Crypto) P2SHAddressWithLength ¶
P2SHAddressWithLength generates a P2PKH bitcoin address with specified length. Deprecated: Please use BitcoinAddress instead.
type Currency ¶
type Currency struct {
Faker *Faker
}
Currency is a faker struct for generating currency data
func (Currency) CurrencyAndCode ¶
CurrencyAndCode returns a random currency name and currency code
type Directory ¶
type Directory struct { Faker *Faker OSResolver OSResolver }
Directory is a faker struct for Directory
func (Directory) Directory ¶
Directory returns a fake directory path (the directory path style is dependent OS dependent)
func (Directory) DriveLetter ¶
DriveLetter returns a fake Win32 drive letter
func (Directory) UnixDirectory ¶
UnixDirectory returns a fake Unix directory path, regardless of the host OS
func (Directory) WindowsDirectory ¶
WindowsDirectory returns a fake Windows directory path, regardless of the host OS
type Faker ¶
type Faker struct {
Generator GeneratorInterface
}
Faker is the Generator struct for Faker
func NewWithSeed ¶
NewWithSeed returns a new instance of Faker instance with a given seed
func (Faker) Asciify ¶
Asciify returns a fake string that replace all "*" characters with random ASCII values from a given string for Faker
func (Faker) BinaryString ¶
func (f Faker) BinaryString() BinaryString
BinaryString returns a fake BinaryString instance for Faker
func (Faker) BoolWithChance ¶
BoolWithChance returns true with a given percentual chance that the value is true, otherwise returns false
func (Faker) Bothify ¶
Bothify returns a fake string that apply Lexify() and Numerify() on a given string for Faker
func (Faker) Int16Between ¶
Int16Between returns a fake Int16 between a given minimum and maximum values for Faker
func (Faker) Int32Between ¶
Int32Between returns a fake Int32 between a given minimum and maximum values for Faker
func (Faker) Int64Between ¶
Int64Between returns a fake Int64 between a given minimum and maximum values for Faker
func (Faker) Int8Between ¶
Int8Between returns a fake Int8 between a given minimum and maximum values for Faker
func (Faker) IntBetween ¶
IntBetween returns a fake Int between a given minimum and maximum values for Faker
func (Faker) Lexify ¶
Lexify returns a fake string that replace all "?" characters with random letters from a given string for Faker
func (Faker) LoremFlickr ¶
func (f Faker) LoremFlickr() LoremFlickr
LoremFlickr returns a fake LoremFlickr instance for Faker
func (Faker) Numerify ¶
Numerify returns a fake string that replace all "#" characters with numbers from a given string for Faker
func (Faker) ProfileImage ¶
func (f Faker) ProfileImage() ProfileImage
ProfileImage returns a fake ProfileImage instance for Faker
func (Faker) RandomDigit ¶
RandomDigit returns a fake random digit for Faker
func (Faker) RandomDigitNot ¶
RandomDigitNot returns a fake random digit for Faker that is not in a list of ignored
func (Faker) RandomDigitNotNull ¶
RandomDigitNotNull returns a fake random digit that is not null for Faker
func (Faker) RandomFloat ¶
RandomFloat returns a fake random float number for Faker
func (Faker) RandomIntElement ¶
RandomIntElement returns a fake random int element form a given list of ints for Faker
func (Faker) RandomLetter ¶
RandomLetter returns a fake random string with a random number of letters for Faker
func (Faker) RandomNumber ¶
RandomNumber returns a fake random integer number for Faker
func (Faker) RandomStringElement ¶
RandomStringElement returns a fake random string element from a given list of strings for Faker
func (Faker) RandomStringMapKey ¶
RandomStringMapKey returns a fake random string key from a given map[string]string for Faker
func (Faker) RandomStringMapValue ¶
RandomStringMapValue returns a fake random string value from a given map[string]string for Faker
func (Faker) RandomStringWithLength ¶
func (Faker) ShuffleString ¶
ShuffleString returns a fake shuffled string from a given string for Faker
func (Faker) UInt16Between ¶
UInt16Between returns a fake UInt16 between a given minimum and maximum values for Faker
func (Faker) UInt32Between ¶
UInt32Between returns a fake UInt32 between a given minimum and maximum values for Faker
func (Faker) UInt64Between ¶
UInt64Between returns a fake UInt64 between a given minimum and maximum values for Faker
func (Faker) UInt8Between ¶
UInt8Between returns a fake UInt8 between a given minimum and maximum values for Faker
func (Faker) UIntBetween ¶
UIntBetween returns a fake UInt between a given minimum and maximum values for Faker
type File ¶
type File struct { Faker *Faker OSResolver OSResolver }
File is a faker struct for File
func (File) AbsoluteFilePath ¶
AbsoluteFilePath returns a fake absolute path to a fake file (style is dependent on OS)
func (File) AbsoluteFilePathForUnix ¶
AbsoluteFilePathForUnix returns a fake absolute unix-style path to a fake file
func (File) AbsoluteFilePathForWindows ¶
AbsoluteFilePathForWindows returns a fake absolute win32-style path to a fake file
func (File) FilenameWithExtension ¶
FilenameWithExtension returns a fake file name with extension
type GeneratorInterface ¶
GeneratorInterface presents an Interface that allows us to subsequently control the returned value more accurately when doing tests by allowing us to use a struct that implements these methods to control the returned value. If not in tests, rand.Rand implements these methods and fufills the interface requirements.
type Genre ¶
type Genre struct {
Faker *Faker
}
Genre is a faker struct for Genre
func (Genre) NameWithDescription ¶
NameWithDescription returns a name and description for Genre
type HTTPClient ¶
HTTPClient does HTTP requests to remote servers
type HTTPClientImpl ¶
type HTTPClientImpl struct{}
HTTPClientImpl is the default implementation of HTTPClient
type Hash ¶
type Hash struct {
Faker *Faker
}
Hash is the faker struct for Hashing Functions
type Image ¶
type Image struct { TempFileCreator TempFileCreator PngEncoder PngEncoder // contains filtered or unexported fields }
Image is a faker struct for Image
type Internet ¶
type Internet struct {
Faker *Faker
}
Internet is a faker struct for Internet
func (Internet) CompanyEmail ¶
CompanyEmail returns a fake company email address for Internet
func (Internet) FreeEmailDomain ¶
FreeEmailDomain returns a fake free email domain for Internet
func (Internet) HTTPMethod ¶
HTTPMethod returns a fake http method for Internet
func (Internet) MacAddress ¶
MacAddress returns a fake mac address for Internet
func (Internet) SafeEmailDomain ¶
SafeEmailDomain returns a fake safe email domain for Internet
func (Internet) StatusCode ¶
StatusCode returns a fake status code for Internet
func (Internet) StatusCodeMessage ¶
StatusCodeMessage returns a fake status code message for Internet
func (Internet) StatusCodeWithMessage ¶
StatusCodeWithMessage returns a fake status code with message for Internet
type Json ¶
type Json struct {
Faker *Faker
}
Json is a faker struct for json files
type Language ¶
type Language struct {
Faker *Faker
}
Language is a faker struct for Language
func (Language) LanguageAbbr ¶
LanguageAbbr returns a fake language name for Language
func (Language) ProgrammingLanguage ¶
ProgrammingLanguage returns a fake programming language for Language
type Lorem ¶
type Lorem struct {
Faker *Faker
}
Lorem is a faker struct for Lorem
func (Lorem) Paragraphs ¶
Paragraphs returns fake paragraphs for Lorem
type LoremFlickr ¶
type LoremFlickr struct { HTTPClient HTTPClient TempFileCreator TempFileCreator // contains filtered or unexported fields }
LoremFlickr is a faker struct for LoremFlickr
type Music ¶
type Music struct {
Faker *Faker
}
Music is a faker struct for Music
type OSResolver ¶
type OSResolver interface {
OS() string
}
OSResolver returns the GOOS value for operating an operating system
type OSResolverImpl ¶
type OSResolverImpl struct{}
OSResolverImpl is the default implementation of OSResolver
func (OSResolverImpl) OS ¶
func (OSResolverImpl) OS() string
OS returns the runtime.GOOS value for the host operating system
type Payment ¶
type Payment struct {
Faker *Faker
}
Payment is a faker struct for Payment
func (Payment) CreditCardExpirationDateString ¶
CreditCardExpirationDateString returns a fake credit card expiration date in string format (i.e. mm/yy) for Payment
func (Payment) CreditCardNumber ¶
CreditCardNumber returns a fake credit card number for Payment
func (Payment) CreditCardType ¶
CreditCardType returns a fake credit card type for Payment
type Person ¶
type Person struct {
Faker *Faker
}
Person is a faker struct for Person
func (Person) Contact ¶
func (p Person) Contact() ContactInfo
Contact will generate a struct with information randomly populated contact information
func (Person) FirstNameFemale ¶
FirstNameFemale returns a fake female first name for Person
func (Person) FirstNameMale ¶
FirstNameMale returns a fake male first mame for Person
func (Person) GenderFemale ¶
GenderFemale returns a fake GenderFemale for Person
func (Person) GenderMale ¶
GenderMale returns a fake GenderMale for Person
func (Person) NameAndGender ¶
NameAndGender returns a fake NameAndGender for Person
func (Person) NameFemale ¶
NameFemale returns a fake NameFemale for Person
func (Person) TitleFemale ¶
TitleFemale returns a fake female title for Person
type Phone ¶
type Phone struct {
Faker *Faker
}
Phone is a faker struct for Phone
func (Phone) E164Number ¶
E164Number returns a fake E164 phone number for Phone
func (Phone) ExchangeCode ¶
ExchangeCode returns a fake exchange code for Phone
func (Phone) TollFreeAreaCode ¶
TollFreeAreaCode returns a fake toll free area code for Phone
func (Phone) ToolFreeNumber ¶
ToolFreeNumber returns a fake tool free number for Phone
type PngEncoder ¶
PngEncoder encodes a image.Image to a io.Writer
type PngEncoderImpl ¶
type PngEncoderImpl struct{}
PngEncoderImpl is the default implementation of the PngEncoder
type ProfileImage ¶
type ProfileImage struct { HTTPClient HTTPClient TempFileCreator TempFileCreator // contains filtered or unexported fields }
ProfileImage is a faker struct for ProfileImage
func (ProfileImage) Image ¶
func (pi ProfileImage) Image() *os.File
Image generates a *os.File with a random profile image using the thispersondoesnotexist.com service
type TempFileCreator ¶
TempFileCreator creates temporary files
type TempFileCreatorImpl ¶
type TempFileCreatorImpl struct{}
TempFileCreatorImpl is the default implementation of TempFileCreator
type Time ¶
type Time struct {
Faker *Faker
}
Time is a faker struct for Time
func (Time) DayOfMonth ¶
DayOfMonth returns a fake day of month for Time
func (Time) RFC3339Nano ¶
RFC3339Nano returns a fake time in RFC3339Nano format for Time
func (Time) TimeBetween ¶
TimeBetween returns a fake time between for Time
type UserAgent ¶
type UserAgent struct {
Faker *Faker
}
UserAgent is a faker struct for UserAgent
func (UserAgent) InternetExplorer ¶
InternetExplorer returns a fake internet explorer UserAgent
type YouTube ¶
type YouTube struct {
Faker *Faker
}
YouTube is a faker struct for YouTube
func (YouTube) GenerateEmbededURL ¶
GenerateEmbededURL returns a fake embedded youtube video url
func (YouTube) GenerateFullURL ¶
GenerateFullURL returns a fake standard youtube video url
func (YouTube) GenerateShareURL ¶
GenerateShareURL returns a fake share youtube video url
func (YouTube) GenerateVideoID ¶
GenerateVideoID returns a youtube video id
Source Files ¶
- address.go
- app.go
- beer.go
- binarystring.go
- blood.go
- boolean.go
- car.go
- color.go
- company.go
- crypto.go
- currency.go
- directory.go
- emoji.go
- faker.go
- file.go
- food.go
- gamer.go
- gender.go
- genre.go
- hash.go
- iban.go
- image.go
- internet.go
- json.go
- language.go
- lorem.go
- lorem_flickr.go
- mimetype.go
- music.go
- payment.go
- person.go
- pet.go
- phone.go
- profile_image.go
- random_element.go
- struct.go
- time.go
- user_agent.go
- utils.go
- uuid.go
- youtube.go