Documentation
¶
Overview ¶
Package faker is just another random data generator for go based on faker.js.
To generate random data for testing usually hard. With faker it's easy to create random data that...
Index ¶
- func Boolean() bool
- func GetStaticSeed() int64
- func Parse(s string) (result string, err error)
- func ResetStaticSeed()
- func SetLocale(l string) error
- func Slugify(s string) string
- func StaticSeed(s int64)
- func ToJSON(data interface{}) (s string, err error)
- func ToXML(data interface{}) (s string, err error)
- func UUID() string
- type Address
- func (addr *Address) BuildingNumberʹ() string
- func (addr *Address) CityPrefixʹ() string
- func (addr *Address) CitySuffixʹ() string
- func (addr *Address) Cityʹ(params ...interface{}) string
- func (addr *Address) CountryCodeʹ() string
- func (addr *Address) Countryʹ() string
- func (addr *Address) Countyʹ() string
- func (addr *Address) Fake()
- func (addr *Address) Latitudeʹ() string
- func (addr *Address) Longitudeʹ() string
- func (addr *Address) SecondaryAddressʹ() string
- func (addr *Address) StateAbbrʹ() string
- func (addr *Address) Stateʹ() string
- func (addr *Address) StreetAddressʹ(params ...interface{}) string
- func (addr *Address) StreetNameʹ() string
- func (addr *Address) StreetPrefixʹ() string
- func (addr *Address) StreetSuffixʹ() string
- func (addr *Address) ToJSON() (s string, err error)
- func (addr *Address) ToXML() (s string, err error)
- func (addr *Address) ZipCodeʹ(params ...interface{}) string
- type BusinessSlogan
- type Card
- type CatchPhrase
- type City
- type Commerce
- func (commerce *Commerce) Colorʹ() string
- func (commerce *Commerce) Departmentʹ() string
- func (commerce *Commerce) Fake()
- func (commerce *Commerce) Priceʹ(params ...interface{}) string
- func (commerce *Commerce) ProductAdjectiveʹ() string
- func (commerce *Commerce) ProductMaterialʹ() string
- func (commerce *Commerce) ProductNameʹ() string
- func (commerce *Commerce) Productʹ() string
- func (commerce *Commerce) ToJSON() (string, error)
- func (commerce *Commerce) ToXML() (string, error)
- type Company
- func (company *Company) BSʹ() string
- func (company *Company) BsAdjectiveʹ() string
- func (company *Company) BsBuzzʹ() string
- func (company *Company) BsNounʹ() string
- func (company *Company) CatchPhraseAdjectiveʹ() string
- func (company *Company) CatchPhraseDescriptorʹ() string
- func (company *Company) CatchPhraseNounʹ() string
- func (company *Company) CatchPhraseʹ() string
- func (company *Company) CompanyNameʹ(params ...interface{}) string
- func (company *Company) CompanySuffixʹ() string
- func (company *Company) Fake()
- func (company *Company) Suffixesʹ() []string
- func (company *Company) ToJSON() (string, error)
- func (company *Company) ToXML() (string, error)
- type CompanyCard
- type ContextualCard
- type Date
- func (d *Date) Betweenʹ(from, to string, params ...interface{}) time.Time
- func (d *Date) Futureʹ(params ...interface{}) time.Time
- func (d *Date) Monthʹ(options ...interface{}) string
- func (d *Date) Pastʹ(params ...interface{}) time.Time
- func (d *Date) Recentʹ(params ...interface{}) time.Time
- func (d *Date) ToJSON() (string, error)
- func (d *Date) ToXML() (string, error)
- func (d *Date) Weekdayʹ(options ...interface{}) string
- type Faker
- type Finance
- func (f *Finance) AccountNameʹ() string
- func (f *Finance) Accountʹ(args ...interface{}) int
- func (f *Finance) Amountʹ(params ...interface{}) string
- func (f *Finance) CurrencyCodeʹ() string
- func (f *Finance) CurrencyNameʹ() string
- func (f *Finance) CurrencySymbolʹ() string
- func (f *Finance) Fake()
- func (f *Finance) Maskʹ(params ...interface{}) string
- func (f *Finance) ToJSON() (string, error)
- func (f *Finance) ToXML() (string, error)
- func (f *Finance) TransactionTypeʹ() string
- type FinanceAccount
- type FinanceCurrency
- type Gender
- type Geo
- type Hacker
- func (h *Hacker) Abbreviationʹ() string
- func (h *Hacker) Adjectiveʹ() string
- func (h *Hacker) Fake()
- func (h *Hacker) IngVerbʹ() string
- func (h *Hacker) Nounʹ() string
- func (h *Hacker) Phraseʹ() string
- func (h *Hacker) ToJSON() (string, error)
- func (h *Hacker) ToXML() (string, error)
- func (h *Hacker) Verbʹ() string
- type Image
- func (image *Image) Abstractʹ(params ...interface{}) string
- func (image *Image) Animalsʹ(params ...interface{}) string
- func (image *Image) Avatarʹ(params ...interface{}) string
- func (image *Image) Businessʹ(params ...interface{}) string
- func (image *Image) Catsʹ(params ...interface{}) string
- func (image *Image) Cityʹ(params ...interface{}) string
- func (image *Image) Fake()
- func (image *Image) Fashionʹ(params ...interface{}) string
- func (image *Image) Foodʹ(params ...interface{}) string
- func (image *Image) Imageʹ(params ...interface{}) string
- func (image *Image) Natureʹ(params ...interface{}) string
- func (image *Image) Nightlifeʹ(params ...interface{}) string
- func (image *Image) Peopleʹ(params ...interface{}) string
- func (image *Image) Sportsʹ(params ...interface{}) string
- func (image *Image) Technicsʹ(params ...interface{}) string
- func (image *Image) ToJSON() (string, error)
- func (image *Image) ToXML() (string, error)
- func (image *Image) Transportʹ(params ...interface{}) string
- type Internet
- func (i *Internet) Avatarʹ() string
- func (i *Internet) Colorʹ(params ...interface{}) string
- func (i *Internet) DomainNameʹ() string
- func (i *Internet) DomainSuffixʹ() string
- func (i *Internet) DomainWordʹ() string
- func (i *Internet) Emailʹ(params ...interface{}) string
- func (i *Internet) ExampleEmail(params ...interface{}) string
- func (i *Internet) Fake()
- func (i *Internet) IPʹ() string
- func (i *Internet) Macʹ() string
- func (i *Internet) Passwordʹ() string
- func (i *Internet) Protocolʹ() string
- func (i *Internet) ToJSON() (string, error)
- func (i *Internet) ToXML() (string, error)
- func (i *Internet) URLʹ() string
- func (i *Internet) UserAgentʹ() string
- func (i *Internet) Usernameʹ(params ...interface{}) string
- type InternetDomain
- type Job
- type Lorem
- func (l *Lorem) Fake()
- func (l *Lorem) Paragraphsʹ(params ...interface{}) string
- func (l *Lorem) Paragraphʹ(params ...interface{}) string
- func (l *Lorem) Sentencesʹ(params ...interface{}) string
- func (l *Lorem) Sentenceʹ(params ...interface{}) string
- func (l *Lorem) Text(params ...interface{}) (val string)
- func (l *Lorem) ToJSON() (string, error)
- func (l *Lorem) ToXML() (string, error)
- func (l *Lorem) Wordsʹ(params ...interface{}) []string
- func (l *Lorem) Wordʹ() string
- type Name
- func (name *Name) Fake()
- func (name *Name) FindNameʹ(params ...interface{}) string
- func (name *Name) FirstNameʹ(params ...interface{}) string
- func (name *Name) JobAreaʹ() string
- func (name *Name) JobDescriptorʹ() string
- func (name *Name) JobTitleʹ() string
- func (name *Name) JobTypeʹ() string
- func (name *Name) LastNameʹ(params ...interface{}) string
- func (name *Name) Prefixʹ(params ...interface{}) string
- func (name *Name) Suffixʹ() string
- func (name *Name) Titleʹ() string
- func (name *Name) ToJSON() (string, error)
- func (name *Name) ToXML() (string, error)
- type Phone
- type Post
- type ProductName
- type Street
- type Transaction
- type UserCard
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetStaticSeed ¶
func GetStaticSeed() int64
func ResetStaticSeed ¶
func ResetStaticSeed()
func StaticSeed ¶
func StaticSeed(s int64)
Types ¶
type Address ¶
type Address struct { ZipCode string `json:"zip_code"` City City `json:"city"` Street Street `json:"street"` Secondary string `json:"secondary_address"` County string `json:"county"` Country string `json:"country"` CountryCode string `json:"country_code"` State string `json:"state"` StateAbbr string `json:"state_abbr"` Geo Geo `json:"geo"` }
Address is complete type of address. For example user needs random Address data.
func (*Address) BuildingNumberʹ ¶
BuildingNumberʹ generate building number based on template in locale data.
func (*Address) CityPrefixʹ ¶
CityPrefixʹ generate prefix for City.
func (*Address) CitySuffixʹ ¶
CitySuffixʹ generate suffix for City.
func (*Address) CountryCodeʹ ¶
CountryCodeʹ generate country code from locale data.
func (*Address) Longitudeʹ ¶
Longitudeʹ generate random longitude position to Geo.
func (*Address) SecondaryAddressʹ ¶
SecondaryAddressʹ generate a secondary address template from locale data.
func (*Address) StateAbbrʹ ¶
StateAbbrʹ generate random abbr of state from locale data.
func (*Address) StreetAddressʹ ¶
StreetAddressʹ generate a street address from locale data.
func (*Address) StreetNameʹ ¶
StreetNameʹ generate random street name for Address, based on first name and last name from Name type.
func (*Address) StreetPrefixʹ ¶
StreetPrefixʹ generate a street prefix from locale data.
func (*Address) StreetSuffixʹ ¶
StreetSuffixʹ generate a street prefix from locale data.
type BusinessSlogan ¶
type Card ¶
type Card struct { Name string Username string Email string Address struct { StreetA string StreetB string StreetC string StreetD string City string State string Country string ZipCode string Geo Geo } Phone string Website string Company CompanyCard Posts []Post AccountHistory []Transaction }
Card is a normal card with complete data. It provides address, company, post.
func CreateCard ¶
func CreateCard() (card Card)
CreateCard create a new card and generate its data with random data.
type CatchPhrase ¶
type Commerce ¶
type Commerce struct { Color string `json:"color"` Department string `json:"color"` Price string `json:"color"` ProductName ProductName `json:"product_name"` }
func (*Commerce) Departmentʹ ¶
func (*Commerce) ProductAdjectiveʹ ¶
func (*Commerce) ProductMaterialʹ ¶
func (*Commerce) ProductNameʹ ¶
type Company ¶
type Company struct { Name string Suffix string CatchPhrase CatchPhrase BusinessSlogan BusinessSlogan }
func (*Company) BsAdjectiveʹ ¶
func (*Company) CatchPhraseAdjectiveʹ ¶
func (*Company) CatchPhraseDescriptorʹ ¶
func (*Company) CatchPhraseNounʹ ¶
func (*Company) CatchPhraseʹ ¶
func (*Company) CompanyNameʹ ¶
func (*Company) CompanySuffixʹ ¶
type CompanyCard ¶
CompanyCard describes company, its catch phrase and slogan.
type ContextualCard ¶
type ContextualCard struct { Name string Username string Avatar string Email string DateOfBirth string Phone string Address struct { Street string Suite string City string ZipCode string Geo Geo } Website string Company CompanyCard }
ContextualCard is a contextual card. Provide address, and company.
func CreateContextualCard ¶
func CreateContextualCard() (card ContextualCard)
CreateContextualCard create a new contextual card and generate its data.
func (*ContextualCard) ToJSON ¶
func (c *ContextualCard) ToJSON() (s string, err error)
ToJSON convert contextual card data to JSON format.
type Date ¶
type Faker ¶
type Faker struct { Name Name Address Address Commerce Commerce Company Company Date Date Finance Finance Hacker Hacker Image Image Internet Internet Lorem Lorem Phone Phone // contains filtered or unexported fields }
Faker is complete structure for all type.
type Finance ¶
type Finance struct { Account FinanceAccount Amount string TransactionType string Currency FinanceCurrency }
Finance
func (*Finance) AccountNameʹ ¶
func (*Finance) CurrencyCodeʹ ¶
func (*Finance) CurrencyNameʹ ¶
func (*Finance) CurrencySymbolʹ ¶
func (*Finance) TransactionTypeʹ ¶
type FinanceAccount ¶
func (*FinanceAccount) Nameʹ ¶
func (fa *FinanceAccount) Nameʹ() string
func (*FinanceAccount) Numberʹ ¶
func (fa *FinanceAccount) Numberʹ(args ...interface{}) int
type FinanceCurrency ¶
Currency
func (*FinanceCurrency) Codeʹ ¶
func (fc *FinanceCurrency) Codeʹ() string
func (*FinanceCurrency) Nameʹ ¶
func (fc *FinanceCurrency) Nameʹ() string
func (*FinanceCurrency) Symbolʹ ¶
func (fc *FinanceCurrency) Symbolʹ() string
type Hacker ¶
type Hacker struct { Abbreviation string Adjective string Noun string Verb string IngVerb string Phrase string }
func (*Hacker) Abbreviationʹ ¶
func (*Hacker) Adjectiveʹ ¶
type Image ¶
func (*Image) Nightlifeʹ ¶
func (*Image) Transportʹ ¶
type Internet ¶
type Internet struct {
Avatar, Email, Username,
Protocol, URL, IP, UserAgent, Color, Mac,
Password string
Domain InternetDomain
}
func (*Internet) DomainNameʹ ¶
func (*Internet) DomainSuffixʹ ¶
func (*Internet) DomainWordʹ ¶
func (*Internet) ExampleEmail ¶
func (*Internet) UserAgentʹ ¶
type InternetDomain ¶
func (*InternetDomain) Nameʹ ¶
func (id *InternetDomain) Nameʹ(params ...interface{}) string
func (*InternetDomain) Suffixʹ ¶
func (id *InternetDomain) Suffixʹ(params ...interface{}) string
func (*InternetDomain) Wordʹ ¶
func (id *InternetDomain) Wordʹ(params ...interface{}) string
type Job ¶
type Job struct { Descriptor string `json:"descriptor"` Area string `json:"area"` Type string `json:"type"` }
Job
type Lorem ¶
type Lorem struct { Word string Words []string Sentence string Sentences string Paragraph string Paragraphs string }
func (*Lorem) Paragraphsʹ ¶
func (*Lorem) Paragraphʹ ¶
func (*Lorem) Sentencesʹ ¶
type Name ¶
type Name struct { FirstName string `json:"first_name"` LastName string `json:"last_name"` Title string `json:"title"` Prefix string `json:"prefix"` Suffix string `json:"suffix"` Job Job `json:"job"` }
Name
func (*Name) FirstNameʹ ¶
FirstNameʹ Generate first name.
func (*Name) JobDescriptorʹ ¶
JobDescriptorʹ Generate job descriptor
type ProductName ¶
type Street ¶
type Street struct { Name string `json:"name"` Address string `json:"address"` Prefix string `json:"prefix"` Suffix string `json:"suffix"` }
Street is a street address.
type Transaction ¶
type Transaction struct { Amount string Date string Business string Name string Type string Account int }
Transaction provides financial transaction structure.
func CreateTransaction ¶
func CreateTransaction() (transaction Transaction)
CreateTransaction create a new transaction card and generate its data.
func (*Transaction) ToJSON ¶
func (c *Transaction) ToJSON() (s string, err error)
ToJSON convert transaction data to JSON format.
type UserCard ¶
type UserCard struct { Name string Username string Email string Address struct { Street string Suite string City string ZipCode string Geo Geo } Phone string Website string Company CompanyCard }
UserCard describes user card, with address and company.
func CreateUserCard ¶
func CreateUserCard() (card UserCard)
CreateUserCard create a new user card and generate its data.