fake: github.com/icrowley/fake Index | Files

package fake

import "github.com/icrowley/fake"

Package fake is the fake data generatror for go (Golang), heavily inspired by forgery and ffaker Ruby gems

Most data and methods are ported from forgery/ffaker Ruby gems.

Currently english and russian languages are available.

For the list of available methods please look at https://godoc.org/github.com/icrowley/fake.

Fake embeds samples data files unless you call UseExternalData(true) in order to be able to work without external files dependencies when compiled, so, if you add new data files or make changes to existing ones don't forget to regenerate data.go file using github.com/mjibson/esc tool and esc -o data.go -pkg fake data command (or you can just use go generate command if you are using Go 1.4 or later).


name := fake.FirstName()
fullname = := fake.FullName()
product := fake.Product()

Changing language:

err := fake.SetLang("ru")
if err != nil {
password := fake.SimplePassword()

Using english fallback:

err := fake.SetLang("ru")
if err != nil {
password := fake.Paragraph()

Using external data:

password := fake.Paragraph()


Package Files

addresses.go credit_cards.go currencies.go data.go dates.go fake.go general.go geo.go internet.go jobs.go lorem_ipsum.go names.go personal.go products.go


var (
    // ErrNoLanguageFn is the error that indicates that given language is not available
    ErrNoLanguageFn = func(lang string) error { return fmt.Errorf("The language passed (%s) is not available", lang) }
    // ErrNoSamplesFn is the error that indicates that there are no samples for the given language
    ErrNoSamplesFn = func(lang string) error { return fmt.Errorf("No samples found for language: %s", lang) }

func Brand Uses

func Brand() string

Brand generates brand name

func Character Uses

func Character() string

Character generates random character in the given language

func Characters Uses

func Characters() string

Characters generates from 1 to 5 characters in the given language

func CharactersN Uses

func CharactersN(n int) string

CharactersN generates n random characters in the given language

func City Uses

func City() string

City generates random city

func Color Uses

func Color() string

Color generates color name

func Company Uses

func Company() string

Company generates company name

func Continent Uses

func Continent() string

Continent generates random continent

func Country Uses

func Country() string

Country generates random country

func CreditCardNum Uses

func CreditCardNum(vendor string) string

CreditCardNum generated credit card number according to the card number rules

func CreditCardType Uses

func CreditCardType() string

CreditCardType returns one of the following credit values: VISA, MasterCard, American Express and Discover

func Currency Uses

func Currency() string

Currency generates currency name

func CurrencyCode Uses

func CurrencyCode() string

CurrencyCode generates currency code

func Day Uses

func Day() int

Day generates day of the month

func Digits Uses

func Digits() string

Digits returns from 1 to 5 digits as a string

func DigitsN Uses

func DigitsN(n int) string

DigitsN returns n digits as a string

func DomainName Uses

func DomainName() string

DomainName generates random domain name

func DomainZone Uses

func DomainZone() string

DomainZone generates random domain zone

func EmailAddress Uses

func EmailAddress() string

EmailAddress generates email address

func EmailBody Uses

func EmailBody() string

EmailBody generates random email body

func EmailSubject Uses

func EmailSubject() string

EmailSubject generates random email subject

func EnFallback Uses

func EnFallback(flag bool)

EnFallback sets the flag that allows fake to fallback to englsh samples if the ones for the used languaged are not available

func FS Uses

func FS(useLocal bool) http.FileSystem

FS returns a http.Filesystem for the embedded assets. If useLocal is true, the filesystem's contents are instead used.

func FemaleFirstName Uses

func FemaleFirstName() string

FemaleFirstName generates female first name

func FemaleFullName Uses

func FemaleFullName() string

FemaleFullName generates female full name it can occasionally include prefix or suffix

func FemaleFullNameWithPrefix Uses

func FemaleFullNameWithPrefix() string

FemaleFullNameWithPrefix generates prefixed female full name if prefixes for the given language are available

func FemaleFullNameWithSuffix Uses

func FemaleFullNameWithSuffix() string

FemaleFullNameWithSuffix generates suffixed female full name if suffixes for the given language are available

func FemaleLastName Uses

func FemaleLastName() string

FemaleLastName generates female last name

func FemalePatronymic Uses

func FemalePatronymic() string

FemalePatronymic generates female patronymic

func FirstName Uses

func FirstName() string

FirstName generates first name

func FullName Uses

func FullName() string

FullName generates full name it can occasionally include prefix or suffix

func FullNameWithPrefix Uses

func FullNameWithPrefix() string

FullNameWithPrefix generates prefixed full name if prefixes for the given language are available

func FullNameWithSuffix Uses

func FullNameWithSuffix() string

FullNameWithSuffix generates suffixed full name if suffixes for the given language are available

func Gender Uses

func Gender() string

Gender generates random gender

func GenderAbbrev Uses

func GenderAbbrev() string

GenderAbbrev returns first downcased letter of the random gender

func GetLangs Uses

func GetLangs() []string

GetLangs returns a slice of available languages

func HexColor Uses

func HexColor() string

HexColor generates hex color name

func HexColorShort Uses

func HexColorShort() string

HexColorShort generates short hex color name

func IPv4 Uses

func IPv4() string

IPv4 generates IPv4 address

func IPv6 Uses

func IPv6() string

IPv6 generates IPv6 address

func Industry Uses

func Industry() string

Industry generates industry name

func JobTitle Uses

func JobTitle() string

JobTitle generates job title

func Language Uses

func Language() string

Language generates random human language

func LastName Uses

func LastName() string

LastName generates last name

func Latitude Uses

func Latitude() float32

Latitude generates latitude (from -90.0 to 90.0)

func LatitudeDegrees Uses

func LatitudeDegrees() int

LatitudeDegrees generates latitude degrees (from -90 to 90)

func LatitudeDirection Uses

func LatitudeDirection() string

LatitudeDirection generates latitude direction (N(orth) o S(outh))

func LatitudeMinutes Uses

func LatitudeMinutes() int

LatitudeMinutes generates latitude minutes (from 0 to 60)

func LatitudeSeconds Uses

func LatitudeSeconds() int

LatitudeSeconds generates latitude seconds (from 0 to 60)

func Longitude Uses

func Longitude() float32

Longitude generates longitude (from -180 to 180)

func LongitudeDegrees Uses

func LongitudeDegrees() int

LongitudeDegrees generates longitude degrees (from -180 to 180)

func LongitudeDirection Uses

func LongitudeDirection() string

LongitudeDirection generates (W(est) or E(ast))

func LongitudeMinutes Uses

func LongitudeMinutes() int

LongitudeMinutes generates (from 0 to 60)

func LongitudeSeconds Uses

func LongitudeSeconds() int

LongitudeSeconds generates (from 0 to 60)

func MaleFirstName Uses

func MaleFirstName() string

MaleFirstName generates male first name

func MaleFullName Uses

func MaleFullName() string

MaleFullName generates male full name it can occasionally include prefix or suffix

func MaleFullNameWithPrefix Uses

func MaleFullNameWithPrefix() string

MaleFullNameWithPrefix generates prefixed male full name if prefixes for the given language are available

func MaleFullNameWithSuffix Uses

func MaleFullNameWithSuffix() string

MaleFullNameWithSuffix generates suffixed male full name if suffixes for the given language are available

func MaleLastName Uses

func MaleLastName() string

MaleLastName generates male last name

func MalePatronymic Uses

func MalePatronymic() string

MalePatronymic generates male patronymic

func Model Uses

func Model() string

Model generates model name that consists of letters and digits, optionally with a hyphen between them

func Month Uses

func Month() string

Month generates month name

func MonthNum Uses

func MonthNum() int

MonthNum generates month number (from 1 to 12)

func MonthShort Uses

func MonthShort() string

MonthShort generates abbreviated month name

func Paragraph Uses

func Paragraph() string

Paragraph generates paragraph

func Paragraphs Uses

func Paragraphs() string

Paragraphs generates from 1 to 5 paragraphs

func ParagraphsN Uses

func ParagraphsN(n int) string

ParagraphsN generates n paragraphs

func Password Uses

func Password(atLeast, atMost int, allowUpper, allowNumeric, allowSpecial bool) string

Password generates password with the length from atLeast to atMOst charachers, allow* parameters specify whether corresponding symbols can be used

func Patronymic Uses

func Patronymic() string

Patronymic generates patronymic

func Phone Uses

func Phone() string

Phone generates random phone number using one of the formats format specified in phone_format file

func Product Uses

func Product() string

Product generates product title as brand + product name

func ProductName Uses

func ProductName() string

ProductName generates product name

func Seed Uses

func Seed(seed int64)

Seed uses the provided seed value to initialize the internal PRNG to a deterministic state.

func Sentence Uses

func Sentence() string

Sentence generates random sentence

func Sentences Uses

func Sentences() string

Sentences generates from 1 to 5 random sentences

func SentencesN Uses

func SentencesN(n int) string

SentencesN generates n random sentences

func SetLang Uses

func SetLang(newLang string) error

SetLang sets the language in which the data should be generated returns error if passed language is not available

func SimplePassword Uses

func SimplePassword() string

SimplePassword is a wrapper around Password, it generates password with the length from 6 to 12 symbols, with upper characters and numeric symbols allowed

func State Uses

func State() string

State generates random state

func StateAbbrev Uses

func StateAbbrev() string

StateAbbrev generates random state abbreviation

func Street Uses

func Street() string

Street generates random street name

func StreetAddress Uses

func StreetAddress() string

StreetAddress generates random street name along with building number

func Title Uses

func Title() string

Title generates from 2 to 5 titleized words

func TopLevelDomain Uses

func TopLevelDomain() string

TopLevelDomain generates random top level domain

func UseExternalData Uses

func UseExternalData(flag bool)

UseExternalData sets the flag that allows using of external files as data providers (fake uses embedded ones by default)

func UserAgent Uses

func UserAgent() string

UserAgent generates a random user agent.

func UserName Uses

func UserName() string

UserName generates user name in one of the following forms first name + last name, letter + last names or concatenation of from 1 to 3 lowercased words

func WeekDay Uses

func WeekDay() string

WeekDay generates name ot the week day

func WeekDayShort Uses

func WeekDayShort() string

WeekDayShort generates abbreviated name of the week day

func WeekdayNum Uses

func WeekdayNum() int

WeekdayNum generates number of the day of the week

func Word Uses

func Word() string

Word generates random word

func Words Uses

func Words() string

Words generates from 1 to 5 random words

func WordsN Uses

func WordsN(n int) string

WordsN generates n random words

func Year Uses

func Year(from, to int) int

Year generates year using the given boundaries

func Zip Uses

func Zip() string

Zip generates random zip code using one of the formats specifies in zip_format file

Package fake imports 14 packages (graph) and is imported by 73 packages. Updated 2020-06-05. Refresh now. Tools for package owners.