README

Faker

Go Go Report Card codecov awesome-go GoReference

Random fake data and struct generator for Go.

  • More than 100 generator functions
  • Struct generator
  • Unique data generator
  • Builtin types support
  • Easily customizable
  • Zero dependencies
  • Recursive infinite loop detector
  • Benchmarks (coming soon)

Installation

go get github.com/pioz/faker

Example

faker.SetSeed(623)

fmt.Println(faker.Username())
fmt.Println(faker.String())
fmt.Println(faker.IntInRange(1, 10))
fmt.Println(faker.CurrencyName())
// Output: spicule
// gzaazJyRGt3jDnVh6ik7R9FO0AU1HcOzdOXbmNVBRQ5pq8n9tHf9B21PIFozLEzsoY4wILvZjTxSLQmD3UOAamDgVR411T3YHleDTgLuz90XSO3NFZm1AnaJiJamVRcNGD2zmi4qWkcjKF3E4JKgn1DiCeC3eSb5WELsw8XqRzlvJqG
// 10
// Myanmar Kyat

Please refer to the godoc for all available functions and more.

Struct Builder Example

faker.SetSeed(622)

// Define a new builder
colorBuilder := func(params ...string) (interface{}, error) {
  return faker.Pick("Red", "Yellow", "Blue", "Black", "White"), nil
}

// Register a new builder named "color" for string type
err := faker.RegisterBuilder("color", "string", colorBuilder)
if err != nil {
  panic(err)
}

type Animal struct {
  Name  string `faker:"username"`
  Color string `faker:"color"` // Use custom color builder
}

type Person struct {
  FirstName string            `faker:"firstName"`         // Any available function case insensitive
  LastName  *string           `faker:"lastName"`          // Pointer are also supported
  Age       int               `faker:"intinrange(0,120)"` // Can call with parameters
  UUID      string            `faker:"uuid;unique"`       // Guarantees a unique value
  Number    int               `faker:"-"`                 // Skip this field
  Code      string            // No tag to use default builder for this field type
  Pet       Animal            // Recursively fill this struct
  Nicknames []string          `faker:"username;len=3"`          // Build an array of size 3 using faker.Username function
  Extra     map[string]string `faker:"stringWithSize(3);len=2"` // map are supported
}

p := Person{}
err = faker.Build(&p)
if err != nil {
  panic(err)
}
fmt.Println(p.FirstName)
fmt.Println(*p.LastName)
fmt.Println(p.Age)
fmt.Println(p.UUID)
fmt.Println(p.Number)
fmt.Println(p.Code)
fmt.Println(p.Pet.Name)
fmt.Println(p.Pet.Color)
fmt.Println(len(p.Nicknames))
fmt.Println(p.Nicknames[0])
fmt.Println(p.Nicknames[1])
fmt.Println(p.Nicknames[2])
fmt.Println(p.Extra)
// Output: Wilber
// Gutkowski
// 25
// ff8d6917-b920-46e6-b1be-dc2d48becfcb
// 0
// z
// honegger
// Red
// 3
// teagan
// polypeptide
// chinfest
// map[70w:3F6 gQS:isq]

Factory

One of the nice things about Faker is that it can also be used as a factory library. In fact when we call the faker.Build function if a value is not zero then it is not modified, leaving the original value. This allows you to create factory functions very easily:

faker.SetSeed(623)

type User struct {
    Username string `faker:"username"`
    Email    string `faker:"email"`
    Country  string `faker:"CountryAlpha2"`
}

italianUserFactory := func() *User {
    u := &User{Country: "IT"}
    faker.Build(u)
    return u
}

italianUser := italianUserFactory()
fmt.Println(italianUser)
// Output: &{spicule hoag@ornamented.biz IT}

Customization

A builder is a variadic function that will take an arbitrary number of strings as arguments and return an interface or an error. This function (builder) can be used to generate fake data and customize the behaviour of Faker. Here an example:

faker.SetSeed(1802)

// Define a new builder
builder := func(params ...string) (interface{}, error) {
    if len(params) > 0 && params[0] == "melee" {
        return faker.Pick("Barbarian", "Bard", "Fighter", "Monk", "Paladin", "Rogue"), nil
    }
    return faker.Pick("Cleric", "Druid", "Ranger", "Sorcerer", "Warlock", "Wizard"), nil
}

// Register a new builder named "dndClass" for string type
err := faker.RegisterBuilder("dndClass", "string", builder)
if err != nil {
    panic(err)
}

player := &struct {
    Class string `faker:"dndClass(melee)"`
    // other fields ...
}{}

// Build a struct with fake data
faker.Build(&player)

fmt.Println(player.Class)
// Output: Paladin

Contributing with new generator functions

If you want to contribute to faker with new generator functions please read this wiki!

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/pioz/faker/issues.

License

The package is available as open source under the terms of the MIT License.

Documentation

Overview

    Package faker is a random data generator and struct fake data generator.

    Index

    Examples

    Constants

    This section is empty.

    Variables

    This section is empty.

    Functions

    func AddressCity

    func AddressCity() string

      AddressCity will build a random city string.

      Example
      Output:
      
      Ntoroko
      

      func AddressFull

      func AddressFull() string

        AddressFull will build a random full address string.

        Example
        Output:
        
        John Snow
        Apt. 248
        943 Wager Street
        Berezniki PR 52209
        Saudi Arabia
        

        func AddressSecondaryAddress

        func AddressSecondaryAddress() string

          AddressSecondaryAddress will build a random secondary address string.

          Example
          Output:
          
          Suite 208
          

          func AddressState

          func AddressState() string

            AddressState will build a random USA state string.

            Example
            Output:
            
            Indiana
            

            func AddressStateCode

            func AddressStateCode() string

              AddressStateCode will build a random USA state code string.

              Example
              Output:
              
              DC
              

              func AddressStreetName

              func AddressStreetName() string

                AddressStreetName will build a random street name string.

                Example
                Output:
                
                Hopton Street
                

                func AddressStreetNumber

                func AddressStreetNumber() string

                  AddressStreetNumber will build a random street number string.

                  Example
                  Output:
                  
                  81-680
                  

                  func AddressZip

                  func AddressZip() string

                    AddressZip will build a random ZIP (postal code) string.

                    Example
                    Output:
                    
                    36168
                    

                    func Article

                    func Article() string

                      Article will build a random article.

                      Example
                      Output:
                      
                      Few can name a sincere chimpanzee that isn't a selective cranberry. They were lost without the straightforward camel that composed their puppy; However, the zebras could be said to resemble tidy bears. Cultured hippopotamus show us how blackberries can be squirrels. In recent years, a cherry sees a nectarine as a resolute bear. This is not to discredit the idea that a crocodile is an emotional prune;
                      An amiable watermelon is a horse of the mind. To be more specific, a panda can hardly be considered an inventive hamster without also being a lime? A camel of the kangaroo is assumed to be a cooperative tiger; Before plums, kangaroos were only melons.
                      In modern times those puppies are nothing more than persimmons. The literature would have us believe that a silly octopus is not but a rabbit. Their blackberry was, in this moment, a protective banana. A puppy is the pear of a grapes. Some posit the amiable pig to be less than helpful.
                      Far from the truth, authors often misinterpret the owl as a calm crocodile, when in actuality it feels more like a placid orange. Extending this logic, some honest turtles are thought of simply as horses. The cherry of an apple becomes a brave chimpanzee; Draped neatly on a hanger, authors often misinterpret the octopus as a happy cranberry, when in actuality it feels more like a harmonious kiwi. The oranges could be said to resemble unusual lemons! Their melon was, in this moment, an impartial hippopotamus. Plums are diligent frogs. By the waya zebra is a thrifty fish.
                      The giraffes could be said to resemble broad-minded kangaroos. The first jolly plum is, in its own way, a grape! Extending this logic, the lobster is an orange. Shouting with happiness, the affable grape comes from a thrifty kiwi. However, their panda was, in this moment, an upbeat spider. An inventive deer's kumquat comes with it the thought that the excited cranberry is a spider.
                      Those bears are nothing more than goldfishes. Authors often misinterpret the bird as an imaginative persimmon, when in actuality it feels more like an intellectual apricot! An apple is an owl from the right perspective. A camel is the fig of an octopus. What we don't know for sure is whether or not foxes are faithful lions. The literature would have us believe that a pleasant tiger is not but a shark.
                      

                      func ArticleWithParagraphCount

                      func ArticleWithParagraphCount(n int) string

                        ArticleWithParagraphCount will build a random article string consisting of n paragraphs.

                        Example
                        Output:
                        
                        The fly of a pig becomes an alert blueberry. The vivacious apricot reveals itself as a powerful lime to those who look! Few can name a resolute turtle that isn't a happy kiwi; The pandas could be said to resemble fair-minded goats. Few can name a modest wolf that isn't a sensible fly! Some generous alligators are thought of simply as chimpanzees. Few can name a thrifty pineapple that isn't a pleasant apricot.
                        By the waybefore chickens, snakes were only lemons. If this was somewhat unclear, a kitten is a cow from the right perspective? Shouting with happiness, rabbits are romantic fishes. A watermelon is a humorous apricot. The willing deer comes from a diplomatic turtle? We can assume that any instance of a strawberry can be construed as an affable fish. Framed in a different way, the dolphins could be said to resemble receptive cherries. An intuitive fly's seal comes with it the thought that the relieved cranberry is a sheep. A blackberry is a panda's cheetah.
                        A turtle sees a panda as an efficient octopus. Seals are compassionate figs; Shouting with happiness, one cannot separate cherries from talented monkeys! Some skillful giraffes are thought of simply as elephants! Few can name an impartial cranberry that isn't a painstaking grapes. A cheetah can hardly be considered a resolute shark without also being a kitten. We know that they were lost without the helpful cherry that composed their giraffe. An energetic goldfish's grapes comes with it the thought that the eminent lemon is a blueberry! As far as he is concerned, their kumquat was, in this moment, a happy eagle. A careful grape's plum comes with it the thought that the industrious turtle is a duck.
                        Their strawberry was, in this moment, a delightful seal. A lively lion is a monkey of the mind. An ant of the plum is assumed to be a kind-hearted frog. It's an undeniable fact, really; they were lost without the brave fish that composed their snail. A mature tiger's zebra comes with it the thought that the resourceful rat is a sheep.
                        In modern times a hamster sees a peach as a helpful fig. In modern times a dog is the fox of a bee. One cannot separate chimpanzees from diplomatic snakes. Some funny seals are thought of simply as grapes; Having been a gymnast, they were lost without the encouraging nectarine that composed their pineapple. This is not to discredit the idea that punctual lions show us how zebras can be pears. Skillful chickens show us how chimpanzees can be lobsters! Few can name an inventive turtle that isn't an adaptable raspberry. Washing and polishing the car,we can assume that any instance of a lime can be construed as an intellectual currant. A cat can hardly be considered a peaceful scorpion without also being a crocodile;
                        

                        func BinaryGender

                        func BinaryGender() string

                          BinaryGender will build a random binary gender string (Male or Female).

                          Example
                          Output:
                          
                          Male
                          

                          func Bool

                          func Bool() bool

                            Bool will build a random boolean value (true or false).

                            Example
                            Output:
                            
                            true
                            false
                            

                            func Build

                            func Build(input interface{}) error

                              Build fills in exported elements of a struct with random data based on the value of `faker` tag of exported elements. The faker tag value can be any available function (case insensitive).

                              Use `faker:"-"` to explicitly skip an element.

                              Use `faker:"skip if FieldName"` to explicitly skip this field if another field (FieldName) is not empty.

                              Use `faker:"unique"` to guarantee a unique value.

                              Use `faker:"len=x"` to specify the length of a slice or the size of a map (if ommitted, will be generated a slice or map with random size between 1 and 8).

                              Built-in supported types are: bool, int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64, float32, float64, string. Other standard library supported types are time.Time and time.Duration. But is really easy to extend faker to add other builders to support other types and or customize faker's behavior (see RegisterBuilder function).

                              Example
                              Output:
                              
                              Elizabeth
                              Thai Nguyen
                              7
                              QtCMxnMc
                              566235bc-4211-4ff2-b966-fa2d49d2b167
                              1267435813
                              
                              Example (Array)
                              Output:
                              
                              [{Username:spicule Email:hoag@ornamented.biz Country:FI} {Username:twelvetone Email:mechanics@ramiform.name Country:TL} {Username:considerate Email:solnit@canonry.biz Country:TG}]
                              
                              Example (ConditionalSkip)
                              Output:
                              
                              true
                              true
                              
                              Example (Factory)
                              Output:
                              
                              &{spicule hoag@ornamented.biz IT}
                              
                              Example (Recursive)
                              Output:
                              
                              Wilber
                              Gutkowski
                              25
                              ff8d6917-b920-46e6-b1be-dc2d48becfcb
                              0
                              zN
                              clung
                              Red
                              3
                              polypeptide
                              chinfest
                              chungchungking
                              map[0w3:F6Y QSi:sq7]
                              

                              func ClearAllUniqCache

                              func ClearAllUniqCache()

                                ClearAllUniqCache delete all results for all groups of run.

                                func ClearUniqCache

                                func ClearUniqCache(group string)

                                  ClearUniqCache delete all results for the group group.

                                  func CountryAlpha2

                                  func CountryAlpha2() string

                                    CountryAlpha2 will build a random 2 characters country code string.

                                    Example
                                    Output:
                                    
                                    ML
                                    

                                    func CountryAlpha3

                                    func CountryAlpha3() string

                                      CountryAlpha3 will build a random 3 characters country code string.

                                      Example
                                      Output:
                                      
                                      TKM
                                      

                                      func CountryFlag

                                      func CountryFlag() string

                                        CountryFlag will build a random emoji flag string.

                                        Example
                                        Output:
                                        
                                        🇳🇷
                                        

                                        func CountryName

                                        func CountryName() string

                                          CountryName will build a random country name string.

                                          Example
                                          Output:
                                          
                                          Rwanda
                                          

                                          func CountryNationality

                                          func CountryNationality() string

                                            CountryNationality will build a random nationality string.

                                            Example
                                            Output:
                                            
                                            Venezuelan
                                            

                                            func CurrencyCode

                                            func CurrencyCode() string

                                              CurrencyCode will build a random currency code string.

                                              Example
                                              Output:
                                              
                                              XOF
                                              

                                              func CurrencyName

                                              func CurrencyName() string

                                                CurrencyName will build a random currency name string.

                                                Example
                                                Output:
                                                
                                                Sierra Leonean Leone
                                                

                                                func CurrencySymbol

                                                func CurrencySymbol() string

                                                  CurrencySymbol will build a random currency symbol string.

                                                  Example
                                                  Output:
                                                  
                                                  

                                                  func Day

                                                  func Day() int

                                                    Day will build a random day between 1 - 31.

                                                    Example
                                                    Output:
                                                    
                                                    5
                                                    

                                                    func Digits

                                                    func Digits() string

                                                      Digits will build a random string of only digits of length between 1 and 8.

                                                      Example
                                                      Output:
                                                      
                                                      615512
                                                      

                                                      func DigitsWithSize

                                                      func DigitsWithSize(size int) string

                                                        DigitsWithSize will build a random string of only digits of length size.

                                                        Example
                                                        Output:
                                                        
                                                        083232
                                                        

                                                        func Domain

                                                        func Domain() string

                                                          Domain will build a random domain string.

                                                          Example
                                                          Output:
                                                          
                                                          lorusso.name
                                                          

                                                          func Duration

                                                          func Duration() time.Duration

                                                            Duration will build a random time.Duration.

                                                            Example
                                                            Output:
                                                            
                                                            -1606331h18m2.623497133s
                                                            

                                                            func DurationInRange

                                                            func DurationInRange(min, max time.Duration) time.Duration

                                                              DurationInRange will build a random time.Duration between min and max included.

                                                              Example
                                                              Output:
                                                              
                                                              158ns
                                                              

                                                              func Email

                                                              func Email() string

                                                                Email will build a random email address string.

                                                                Example
                                                                Output:
                                                                
                                                                homocercal@fulmer.net
                                                                

                                                                func FemaleFirstName

                                                                func FemaleFirstName() string

                                                                  FemaleFirstName will build a random female first name string.

                                                                  Example
                                                                  Output:
                                                                  
                                                                  Sharell
                                                                  

                                                                  func FirstName

                                                                  func FirstName() string

                                                                    FirstName will build a random first name string.

                                                                    Example
                                                                    Output:
                                                                    
                                                                    Barney
                                                                    

                                                                    func Float32

                                                                    func Float32() float32

                                                                      Float32 will build a random float32.

                                                                      Example
                                                                      Output:
                                                                      
                                                                      1.5426473e+38
                                                                      

                                                                      func Float32InRange

                                                                      func Float32InRange(min, max float32) float32

                                                                        Float32InRange will build a random float32 between min and max included.

                                                                        Example
                                                                        Output:
                                                                        
                                                                        18.961363
                                                                        -15.832848
                                                                        -20
                                                                        

                                                                        func Float64

                                                                        func Float64() float64

                                                                          Float64 will build a random float64.

                                                                          Example
                                                                          Output:
                                                                          
                                                                          6.696671980874496e+307
                                                                          

                                                                          func Float64InRange

                                                                          func Float64InRange(min, max float64) float64

                                                                            Float64InRange will build a random float64 between min and max included.

                                                                            Example
                                                                            Output:
                                                                            
                                                                            18.120965248489753
                                                                            -14.513652135502497
                                                                            -20
                                                                            

                                                                            func FreeEmail

                                                                            func FreeEmail() string

                                                                              FreeEmail will build a random free email address string (gmail, hotmail, yahoo...).

                                                                              Example
                                                                              Output:
                                                                              
                                                                              atlas@gmail.com
                                                                              

                                                                              func FullName

                                                                              func FullName() string

                                                                                FullName will build a random full name string.

                                                                                Example
                                                                                Output:
                                                                                
                                                                                Sawyer Littel
                                                                                

                                                                                func Gender

                                                                                func Gender() string

                                                                                  Gender will build a random gender string.

                                                                                  Example
                                                                                  Output:
                                                                                  
                                                                                  Cisgender Male
                                                                                  

                                                                                  func GetData

                                                                                  func GetData(namespace, group string) (interface{}, error)

                                                                                    GetData return a random value of the Pool present in the group group with namespace namespace or error if the pool does not exist. Faker organize fake data in a map of string and map of string and array of interface. The keys of the first level map are called namespaces, the keys of the second level map are called groups.

                                                                                    Example
                                                                                    Output:
                                                                                    
                                                                                    New York
                                                                                    

                                                                                    func Hour

                                                                                    func Hour() int

                                                                                      Hour will build a random hour in military time.

                                                                                      Example
                                                                                      Output:
                                                                                      
                                                                                      9
                                                                                      

                                                                                      func Int

                                                                                      func Int() int

                                                                                        Int will build a random int.

                                                                                        Example
                                                                                        Output:
                                                                                        
                                                                                        477987042
                                                                                        

                                                                                        func Int16

                                                                                        func Int16() int16

                                                                                          Int16 will build a random int16.

                                                                                          Example
                                                                                          Output:
                                                                                          
                                                                                          -24938
                                                                                          

                                                                                          func Int16InRange

                                                                                          func Int16InRange(min, max int16) int16

                                                                                            Int16InRange will build a random int16 between min and max included.

                                                                                            Example
                                                                                            Output:
                                                                                            
                                                                                            14
                                                                                            -16
                                                                                            -20
                                                                                            

                                                                                            func Int32

                                                                                            func Int32() int32

                                                                                              Int32 will build a random int32.

                                                                                              Example
                                                                                              Output:
                                                                                              
                                                                                              -417194768
                                                                                              

                                                                                              func Int32InRange

                                                                                              func Int32InRange(min, max int32) int32

                                                                                                Int32InRange will build a random int32 between min and max included.

                                                                                                Example
                                                                                                Output:
                                                                                                
                                                                                                15
                                                                                                -16
                                                                                                -20
                                                                                                

                                                                                                func Int64

                                                                                                func Int64() int64

                                                                                                  Int64 will build a random int64.

                                                                                                  Example
                                                                                                  Output:
                                                                                                  
                                                                                                  -5917743806733054187
                                                                                                  

                                                                                                  func Int64InRange

                                                                                                  func Int64InRange(min, max int64) int64

                                                                                                    Int64InRange will build a random int64 between min and max included.

                                                                                                    Example
                                                                                                    Output:
                                                                                                    
                                                                                                    10
                                                                                                    -19
                                                                                                    -20
                                                                                                    

                                                                                                    func Int8

                                                                                                    func Int8() int8

                                                                                                      Int8 will build a random int8.

                                                                                                      Example
                                                                                                      Output:
                                                                                                      
                                                                                                      -101
                                                                                                      

                                                                                                      func Int8InRange

                                                                                                      func Int8InRange(min, max int8) int8

                                                                                                        Int8InRange will build a random int8 between min and max included.

                                                                                                        Example
                                                                                                        Output:
                                                                                                        
                                                                                                        15
                                                                                                        -14
                                                                                                        -20
                                                                                                        

                                                                                                        func IntInRange

                                                                                                        func IntInRange(min, max int) int

                                                                                                          IntInRange will build a random int between min and max included.

                                                                                                          Example
                                                                                                          Output:
                                                                                                          
                                                                                                          16
                                                                                                          -14
                                                                                                          -20
                                                                                                          

                                                                                                          func LangCode

                                                                                                          func LangCode() string

                                                                                                            LangCode will build a random language code string.

                                                                                                            Example
                                                                                                            Output:
                                                                                                            
                                                                                                            sk
                                                                                                            

                                                                                                            func LangName

                                                                                                            func LangName() string

                                                                                                              LangName will build a random language name string.

                                                                                                              Example
                                                                                                              Output:
                                                                                                              
                                                                                                              Kirghiz
                                                                                                              

                                                                                                              func LastName

                                                                                                              func LastName() string

                                                                                                                LastName will build a random last name string.

                                                                                                                Example
                                                                                                                Output:
                                                                                                                
                                                                                                                Ankunding
                                                                                                                

                                                                                                                func Letters

                                                                                                                func Letters() string

                                                                                                                  Letters will build a random string of only letters of length between 1 and 8.

                                                                                                                  Example
                                                                                                                  Output:
                                                                                                                  
                                                                                                                  HZ
                                                                                                                  

                                                                                                                  func LettersWithSize

                                                                                                                  func LettersWithSize(size int) string

                                                                                                                    LettersWithSize will build a random string of only letters of length size.

                                                                                                                    Example
                                                                                                                    Output:
                                                                                                                    
                                                                                                                    ZHCbqwV
                                                                                                                    

                                                                                                                    func Lexify

                                                                                                                    func Lexify(str string) string

                                                                                                                      Lexify will replace all occurrences of "?" in str with a random letter.

                                                                                                                      Example
                                                                                                                      Output:
                                                                                                                      
                                                                                                                      abxcZhdZ
                                                                                                                      

                                                                                                                      func MaleFirstName

                                                                                                                      func MaleFirstName() string

                                                                                                                        MaleFirstName will build a random male first name string.

                                                                                                                        Example
                                                                                                                        Output:
                                                                                                                        
                                                                                                                        Lucien
                                                                                                                        

                                                                                                                        func Minute

                                                                                                                        func Minute() int

                                                                                                                          Minute will build a random minute.

                                                                                                                          Example
                                                                                                                          Output:
                                                                                                                          
                                                                                                                          40
                                                                                                                          

                                                                                                                          func Month

                                                                                                                          func Month() string

                                                                                                                            Month will build a random month string.

                                                                                                                            Example
                                                                                                                            Output:
                                                                                                                            
                                                                                                                            July
                                                                                                                            

                                                                                                                            func NameInitials

                                                                                                                            func NameInitials() string

                                                                                                                              NameInitials will build a random name initials of 2 characters string.

                                                                                                                              Example
                                                                                                                              Output:
                                                                                                                              
                                                                                                                              NP
                                                                                                                              

                                                                                                                              func NamePrefix

                                                                                                                              func NamePrefix() string

                                                                                                                                NamePrefix will build a random name prefix string.

                                                                                                                                Example
                                                                                                                                Output:
                                                                                                                                
                                                                                                                                Msgr.
                                                                                                                                

                                                                                                                                func NameSuffix

                                                                                                                                func NameSuffix() string

                                                                                                                                  NameSuffix will build a random name suffix string.

                                                                                                                                  Example
                                                                                                                                  Output:
                                                                                                                                  
                                                                                                                                  PhD
                                                                                                                                  

                                                                                                                                  func NanoSecond

                                                                                                                                  func NanoSecond() int

                                                                                                                                    NanoSecond will build a random nano second.

                                                                                                                                    Example
                                                                                                                                    Output:
                                                                                                                                    
                                                                                                                                    299642157
                                                                                                                                    

                                                                                                                                    func NeutralFirstName

                                                                                                                                    func NeutralFirstName() string

                                                                                                                                      NeutralFirstName will build a random neutral first name string.

                                                                                                                                      Example
                                                                                                                                      Output:
                                                                                                                                      
                                                                                                                                      Hayden
                                                                                                                                      

                                                                                                                                      func Numerify

                                                                                                                                      func Numerify(str string) string

                                                                                                                                        Numerify will replace all occurrences of "?" in str with a random digit.

                                                                                                                                        Example
                                                                                                                                        Output:
                                                                                                                                        
                                                                                                                                        ab5c30d754
                                                                                                                                        

                                                                                                                                        func Paragraph

                                                                                                                                        func Paragraph() string

                                                                                                                                          Paragraph will build a random paragraph.

                                                                                                                                          Example
                                                                                                                                          Output:
                                                                                                                                          
                                                                                                                                          A currant is a deer from the right perspective. Having been a gymnast, authors often misinterpret the tangerine as an intelligent camel, when in actuality it feels more like a communicative bear; As far as he is concerned, a shark is the zebra of a dog. Those kumquats are nothing more than elephants. It's an undeniable fact, really; some posit the hilarious prune to be less than intellectual. A communicative zebra's goat comes with it the thought that the honest snake is a cow? Washing and polishing the car,excited cranberries show us how grapefruits can be elephants. One cannot separate bears from dynamic cows! One cannot separate cats from stimulating spiders. Extending this logic, a goldfish can hardly be considered a succinct spider without also being a cheetah.
                                                                                                                                          

                                                                                                                                          func ParagraphWithSentenceCount

                                                                                                                                          func ParagraphWithSentenceCount(n int) string

                                                                                                                                            ParagraphWithSentenceCount will build a random paragraph string consisting of n sentences.

                                                                                                                                            Example
                                                                                                                                            Output:
                                                                                                                                            
                                                                                                                                            Their squirrel was, in this moment, an affable goat. A camel is a lion's panda! In modern times dazzling lemons show us how plums can be horses. This is not to discredit the idea that a cat can hardly be considered an amused fish without also being a lobster? An exuberant goldfish is a wolf of the mind.
                                                                                                                                            

                                                                                                                                            func Parameterize

                                                                                                                                            func Parameterize(str string) string

                                                                                                                                              Parameterize replaces special characters in str so that it may be used as part of a 'pretty' URL.

                                                                                                                                              Example
                                                                                                                                              Output:
                                                                                                                                              
                                                                                                                                              the-amazing-zanz-153
                                                                                                                                              

                                                                                                                                              func PhoneNumber

                                                                                                                                              func PhoneNumber() string

                                                                                                                                                PhoneNumber will build a random phone number string.

                                                                                                                                                Example
                                                                                                                                                Output:
                                                                                                                                                
                                                                                                                                                152.380.7298
                                                                                                                                                

                                                                                                                                                func Pick

                                                                                                                                                func Pick(pool ...string) string

                                                                                                                                                  Pick returns a random string among those passed as parameters.

                                                                                                                                                  Example
                                                                                                                                                  Output:
                                                                                                                                                  
                                                                                                                                                  dog
                                                                                                                                                  

                                                                                                                                                  func RegisterBuilder

                                                                                                                                                  func RegisterBuilder(builderName, builderType string, fn builderFunc) error

                                                                                                                                                    RegisterBuilder register a new builder. A builder is a variadic function that will take an arbitrary number of strings as arguments and return an interface or an error. This function (builder) can be used to generate fake data. builderName is the name of the builder, builderType is the type of the interface returned by the builder.

                                                                                                                                                    Example
                                                                                                                                                    Output:
                                                                                                                                                    
                                                                                                                                                    Paladin
                                                                                                                                                    

                                                                                                                                                    func SafeEmail

                                                                                                                                                    func SafeEmail() string

                                                                                                                                                      SafeEmail will build a random email address string whose domain is always example.com.

                                                                                                                                                      Example
                                                                                                                                                      Output:
                                                                                                                                                      
                                                                                                                                                      disbelieve@example.com
                                                                                                                                                      

                                                                                                                                                      func Sample

                                                                                                                                                      func Sample(slice interface{}) interface{}

                                                                                                                                                        Sample return a random element of slice. Sample panics if slice is not a slice, is nil or is empty.

                                                                                                                                                        Example
                                                                                                                                                        Output:
                                                                                                                                                        
                                                                                                                                                        5
                                                                                                                                                        

                                                                                                                                                        func Second

                                                                                                                                                        func Second() int

                                                                                                                                                          Second will build a random second.

                                                                                                                                                          Example
                                                                                                                                                          Output:
                                                                                                                                                          
                                                                                                                                                          51
                                                                                                                                                          

                                                                                                                                                          func Sentence

                                                                                                                                                          func Sentence() string

                                                                                                                                                            Sentence will build a random sentence string.

                                                                                                                                                            Example
                                                                                                                                                            Output:
                                                                                                                                                            
                                                                                                                                                            A knowledgeable pomegranate without peaches is truly a panda of compassionate sharks.
                                                                                                                                                            

                                                                                                                                                            func SetPool

                                                                                                                                                            func SetPool(namespace, group string, pool Pool)

                                                                                                                                                              SetPool add a new Pool under the group group with namespace namespace (see GetData).

                                                                                                                                                              func SetPoolGroup

                                                                                                                                                              func SetPoolGroup(namespace string, poolGroup PoolGroup)

                                                                                                                                                                SetPoolGroup add a new PoolGroup under the namespace namespace (see GetData).

                                                                                                                                                                func SetRand

                                                                                                                                                                func SetRand(r *rand.Rand)

                                                                                                                                                                  SetRand set a new source of random numbers (see rand.Rand). The default source is:

                                                                                                                                                                  rand.New(rand.NewSource(time.Now().UnixNano()))
                                                                                                                                                                  

                                                                                                                                                                  func SetSeed

                                                                                                                                                                  func SetSeed(seed int64)

                                                                                                                                                                    SetSeed uses the provided seed value to initialize the generator to a deterministic state (see rand.Seed).

                                                                                                                                                                    func ShortBinaryGender

                                                                                                                                                                    func ShortBinaryGender() string

                                                                                                                                                                      ShortBinaryGender will build a random short binary gender string (m or f).

                                                                                                                                                                      Example
                                                                                                                                                                      Output:
                                                                                                                                                                      
                                                                                                                                                                      m
                                                                                                                                                                      

                                                                                                                                                                      func Slice

                                                                                                                                                                      func Slice(size int, fn func() interface{}) []interface{}

                                                                                                                                                                        Slice will build a random slice of interface{} of length n. The elements of the slice are genereted by the function fn.

                                                                                                                                                                        Example
                                                                                                                                                                        Output:
                                                                                                                                                                        
                                                                                                                                                                        [6 9 9]
                                                                                                                                                                        

                                                                                                                                                                        func Slug

                                                                                                                                                                        func Slug() string

                                                                                                                                                                          Slug will build a random slug string.

                                                                                                                                                                          Example
                                                                                                                                                                          Output:
                                                                                                                                                                          
                                                                                                                                                                          a-reliable-seal-s-bee-comes-with-it-the-thought-that-the-adventurous-giraffe-is-an-alligator
                                                                                                                                                                          

                                                                                                                                                                          func String

                                                                                                                                                                          func String() string

                                                                                                                                                                            String will build a random string of length between 1 and 8.

                                                                                                                                                                            Example
                                                                                                                                                                            Output:
                                                                                                                                                                            
                                                                                                                                                                            PMIWvi6i
                                                                                                                                                                            

                                                                                                                                                                            func StringWithSize

                                                                                                                                                                            func StringWithSize(size int) string

                                                                                                                                                                              StringWithSize will build a random string of length size.

                                                                                                                                                                              Example
                                                                                                                                                                              Output:
                                                                                                                                                                              
                                                                                                                                                                              zVCVi
                                                                                                                                                                              

                                                                                                                                                                              func Time

                                                                                                                                                                              func Time() time.Time

                                                                                                                                                                                Time will build a random time.Time.

                                                                                                                                                                                func TimeInRange

                                                                                                                                                                                func TimeInRange(min, max time.Time) time.Time

                                                                                                                                                                                  TimeInRange will build a random time.Time between min and max included.

                                                                                                                                                                                  func TimeZone

                                                                                                                                                                                  func TimeZone() string

                                                                                                                                                                                    TimeZone will build a random timezone string.

                                                                                                                                                                                    Example
                                                                                                                                                                                    Output:
                                                                                                                                                                                    
                                                                                                                                                                                    Venezuela Standard Time
                                                                                                                                                                                    

                                                                                                                                                                                    func TimeZoneAbbr

                                                                                                                                                                                    func TimeZoneAbbr() string

                                                                                                                                                                                      TimeZoneAbbr will build a random abbreviated timezone string.

                                                                                                                                                                                      Example
                                                                                                                                                                                      Output:
                                                                                                                                                                                      
                                                                                                                                                                                      MEDT
                                                                                                                                                                                      

                                                                                                                                                                                      func TimeZoneFull

                                                                                                                                                                                      func TimeZoneFull() string

                                                                                                                                                                                        TimeZoneFull will build a random full timezone string.

                                                                                                                                                                                        Example
                                                                                                                                                                                        Output:
                                                                                                                                                                                        
                                                                                                                                                                                        (UTC-03:00) Cayenne, Fortaleza
                                                                                                                                                                                        

                                                                                                                                                                                        func TimeZoneOffset

                                                                                                                                                                                        func TimeZoneOffset() float32

                                                                                                                                                                                          TimeZoneOffset will build a random timezone offset.

                                                                                                                                                                                          Example
                                                                                                                                                                                          Output:
                                                                                                                                                                                          
                                                                                                                                                                                          -1
                                                                                                                                                                                          

                                                                                                                                                                                          func TimeZoneRegion

                                                                                                                                                                                          func TimeZoneRegion() string

                                                                                                                                                                                            TimeZoneRegion will build a random timezone region string.

                                                                                                                                                                                            Example
                                                                                                                                                                                            Output:
                                                                                                                                                                                            
                                                                                                                                                                                            Africa/Accra
                                                                                                                                                                                            

                                                                                                                                                                                            func URL

                                                                                                                                                                                            func URL() string

                                                                                                                                                                                              URL will build a random URL string.

                                                                                                                                                                                              Example
                                                                                                                                                                                              Output:
                                                                                                                                                                                              
                                                                                                                                                                                              https://www.mcmillon.info/this-could-be-or-perhaps-their-alligator-was-in-this-moment-an-eager-spider
                                                                                                                                                                                              

                                                                                                                                                                                              func UUID

                                                                                                                                                                                              func UUID() string

                                                                                                                                                                                                UUID will build a random UUID string.

                                                                                                                                                                                                Example
                                                                                                                                                                                                Output:
                                                                                                                                                                                                
                                                                                                                                                                                                40abb44c-895e-45b8-9f67-cc02a811744a
                                                                                                                                                                                                

                                                                                                                                                                                                func Uint

                                                                                                                                                                                                func Uint() uint

                                                                                                                                                                                                  Uint will build a random uint.

                                                                                                                                                                                                  Example
                                                                                                                                                                                                  Output:
                                                                                                                                                                                                  
                                                                                                                                                                                                  2486533097
                                                                                                                                                                                                  

                                                                                                                                                                                                  func Uint16

                                                                                                                                                                                                  func Uint16() uint16

                                                                                                                                                                                                    Uint16 will build a random uint16.

                                                                                                                                                                                                    Example
                                                                                                                                                                                                    Output:
                                                                                                                                                                                                    
                                                                                                                                                                                                    29810
                                                                                                                                                                                                    

                                                                                                                                                                                                    func Uint16InRange

                                                                                                                                                                                                    func Uint16InRange(min, max uint16) uint16

                                                                                                                                                                                                      Uint16InRange will build a random uint16 between min and max included.

                                                                                                                                                                                                      Example
                                                                                                                                                                                                      Output:
                                                                                                                                                                                                      
                                                                                                                                                                                                      13
                                                                                                                                                                                                      20
                                                                                                                                                                                                      

                                                                                                                                                                                                      func Uint32

                                                                                                                                                                                                      func Uint32() uint32

                                                                                                                                                                                                        Uint32 will build a random uint32.

                                                                                                                                                                                                        Example
                                                                                                                                                                                                        Output:
                                                                                                                                                                                                        
                                                                                                                                                                                                        1185777406
                                                                                                                                                                                                        

                                                                                                                                                                                                        func Uint32InRange

                                                                                                                                                                                                        func Uint32InRange(min, max uint32) uint32

                                                                                                                                                                                                          Uint32InRange will build a random uint32 between min and max included.

                                                                                                                                                                                                          Example
                                                                                                                                                                                                          Output:
                                                                                                                                                                                                          
                                                                                                                                                                                                          16
                                                                                                                                                                                                          20
                                                                                                                                                                                                          

                                                                                                                                                                                                          func Uint64

                                                                                                                                                                                                          func Uint64() uint64

                                                                                                                                                                                                            Uint64 will build a random uint64.

                                                                                                                                                                                                            Example
                                                                                                                                                                                                            Output:
                                                                                                                                                                                                            
                                                                                                                                                                                                            16676020418646319060
                                                                                                                                                                                                            

                                                                                                                                                                                                            func Uint64InRange

                                                                                                                                                                                                            func Uint64InRange(min, max uint64) uint64

                                                                                                                                                                                                              Uint64InRange will build a random uint64 between min and max included.

                                                                                                                                                                                                              Example
                                                                                                                                                                                                              Output:
                                                                                                                                                                                                              
                                                                                                                                                                                                              13
                                                                                                                                                                                                              20
                                                                                                                                                                                                              

                                                                                                                                                                                                              func Uint8

                                                                                                                                                                                                              func Uint8() uint8

                                                                                                                                                                                                                Uint8 will build a random uint8.

                                                                                                                                                                                                                Example
                                                                                                                                                                                                                Output:
                                                                                                                                                                                                                
                                                                                                                                                                                                                231
                                                                                                                                                                                                                

                                                                                                                                                                                                                func Uint8InRange

                                                                                                                                                                                                                func Uint8InRange(min, max uint8) uint8

                                                                                                                                                                                                                  Uint8InRange will build a random uint8 between min and max included.

                                                                                                                                                                                                                  Example
                                                                                                                                                                                                                  Output:
                                                                                                                                                                                                                  
                                                                                                                                                                                                                  18
                                                                                                                                                                                                                  20
                                                                                                                                                                                                                  

                                                                                                                                                                                                                  func UintInRange

                                                                                                                                                                                                                  func UintInRange(min, max uint) uint

                                                                                                                                                                                                                    UintInRange will build a random uint between min and max included.

                                                                                                                                                                                                                    Example
                                                                                                                                                                                                                    Output:
                                                                                                                                                                                                                    
                                                                                                                                                                                                                    15
                                                                                                                                                                                                                    20
                                                                                                                                                                                                                    

                                                                                                                                                                                                                    func Uniq

                                                                                                                                                                                                                    func Uniq(group string, maxRetry int, fn func() (interface{}, error)) (interface{}, error)

                                                                                                                                                                                                                      Uniq run max maxRetry times fn function until fn returns a unique value for the group of runs group. Returns error if the number of runs reach maxRetry. If maxRetry is zero use default value that is 10000.

                                                                                                                                                                                                                      Example
                                                                                                                                                                                                                      Output:
                                                                                                                                                                                                                      
                                                                                                                                                                                                                      1
                                                                                                                                                                                                                      0
                                                                                                                                                                                                                      0
                                                                                                                                                                                                                      

                                                                                                                                                                                                                      func UniqSlice

                                                                                                                                                                                                                      func UniqSlice(size int, group string, maxRetry int, fn func() (interface{}, error)) ([]interface{}, error)

                                                                                                                                                                                                                        UniqSlice run max maxRetry times fn function until fn returns a unique slice for the group of runs group. Returns error if the number of runs reach maxRetry. If maxRetry is zero use default value that is 10000.

                                                                                                                                                                                                                        func UnregisterBuilder

                                                                                                                                                                                                                        func UnregisterBuilder(builderName, builderType string) error

                                                                                                                                                                                                                          UnregisterBuilder unregister/remove a builder.

                                                                                                                                                                                                                          func Username

                                                                                                                                                                                                                          func Username() string

                                                                                                                                                                                                                            Username will build a random username string.

                                                                                                                                                                                                                            Example
                                                                                                                                                                                                                            Output:
                                                                                                                                                                                                                            
                                                                                                                                                                                                                            polychasium
                                                                                                                                                                                                                            

                                                                                                                                                                                                                            func WeekDay

                                                                                                                                                                                                                            func WeekDay() string

                                                                                                                                                                                                                              WeekDay will build a random weekday string (Monday-Sunday).

                                                                                                                                                                                                                              Example
                                                                                                                                                                                                                              Output:
                                                                                                                                                                                                                              
                                                                                                                                                                                                                              Saturday
                                                                                                                                                                                                                              

                                                                                                                                                                                                                              func Year

                                                                                                                                                                                                                              func Year() int

                                                                                                                                                                                                                                Year will build a random year between 1900 - 2100.

                                                                                                                                                                                                                                Example
                                                                                                                                                                                                                                Output:
                                                                                                                                                                                                                                
                                                                                                                                                                                                                                2032
                                                                                                                                                                                                                                

                                                                                                                                                                                                                                Types

                                                                                                                                                                                                                                type Pool

                                                                                                                                                                                                                                type Pool []interface{}

                                                                                                                                                                                                                                  Pool type is a slice that contains fake data.

                                                                                                                                                                                                                                  type PoolData

                                                                                                                                                                                                                                  type PoolData map[string]PoolGroup

                                                                                                                                                                                                                                    PoolData type is a map that groups PoolGroup types.

                                                                                                                                                                                                                                    type PoolGroup

                                                                                                                                                                                                                                    type PoolGroup map[string]Pool

                                                                                                                                                                                                                                      PoolGroup type is a map that groups Pool types.