Skip to content
Random fake data generator written in go
Go
Branch: master
Clone or download
Latest commit cf7158d Dec 30, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github
data Animals - added Animal, AnimalType, FarmAnimal, Cat, Dog Dec 10, 2019
.travis.yml travis - updated to stable Apr 12, 2019
BENCHMARKS.md
CODE_OF_CONDUCT.md Create CODE_OF_CONDUCT.md Jul 28, 2017
CONTRIBUTING.md Create CONTRIBUTING.md Jul 28, 2017
LICENSE.txt
README.md readme - updated lat and long input Dec 16, 2019
TODO.txt
address.go
address_test.go fixes digit 9 missing from randDigit Nov 17, 2018
animal.go Animals - added Animal, AnimalType, FarmAnimal, Cat, Dog Dec 10, 2019
animal_test.go Animals - added Animal, AnimalType, FarmAnimal, Cat, Dog Dec 10, 2019
beer.go
beer_test.go beer - i added BEEEER!!! Jun 2, 2017
bool.go lint - minor lint update Aug 1, 2019
bool_test.go
color.go fix: HexColor are now valid Jul 20, 2019
color_test.go fix: HexColor are now valid Jul 20, 2019
company.go golint - rand golint and address any issues. Jun 29, 2015
company_test.go testing - coverage update Apr 29, 2017
contact.go lint - minor lint update Aug 1, 2019
contact_test.go fixes digit 9 missing from randDigit Nov 17, 2018
currency.go
currency_test.go price - added price Apr 23, 2018
datetime.go
datetime_test.go
doc.go doc - simplification of godoc main description Jul 19, 2019
faker.go
faker_test.go fixes digit 9 missing from randDigit Nov 17, 2018
file.go golint - rand golint and address any issues. Jun 29, 2015
file_test.go
generate.go
generate_test.go fixes digit 9 missing from randDigit Nov 17, 2018
go.mod go mod - going to version 3 to "fix" the incompatible "issue" Oct 9, 2019
hacker.go hacker - added hacker info Jun 2, 2017
hacker_test.go hacker - fix seed number Jul 21, 2019
hipster.go
hipster_test.go Hipster Sentence/Paragraph optimized memory allocations ~60% Nov 3, 2018
image.go
image_test.go updates - updated image url to use one that has more up time. fixes t… Jan 22, 2019
internet.go
internet_test.go misc - test and minor update Aug 1, 2019
job.go golint - rand golint and address any issues. Jun 29, 2015
job_test.go Job - added job info struct. Jun 16, 2015
languages.go
languages_test.go
log_level.go go mod - going to version 3 to "fix" the incompatible "issue" Oct 9, 2019
log_level_test.go
logo.png
map.go
map_test.go map - fixed test coverage Oct 9, 2019
misc.go go mod - going to version 3 to "fix" the incompatible "issue" Oct 9, 2019
misc_test.go go mod - going to version 3 to "fix" the incompatible "issue" Oct 9, 2019
name.go
name_test.go golint - rand golint and address any issues. Jun 29, 2015
number.go numbers - added float32 and float64 ranges Oct 11, 2018
number_test.go fixes digit 9 missing from randDigit Nov 17, 2018
password.go password - updated to make password implement at least 1 of each type… Aug 9, 2018
password_test.go
payment.go
payment_test.go
person.go
person_test.go updates - updated image url to use one that has more up time. fixes t… Jan 22, 2019
status_code.go
status_code_test.go Supports random HTTP status code Oct 25, 2017
string.go
string_test.go fixes digit 9 missing from randDigit Nov 17, 2018
struct.go
struct_test.go struct - minor update to fix seeing it in docs and minor cleanup Jul 19, 2019
unique.go
unique_test.go uuid - swapped UniqueID with UUID and used version 4 Nov 9, 2017
user_agent.go data - cleaned up and separated data information Jun 1, 2017
user_agent_test.go
vehicle.go vehicle - updated comments Jan 25, 2019
vehicle_test.go updates - updated image url to use one that has more up time. fixes t… Jan 22, 2019
words.go words - added questions and quotes Jan 25, 2019
words_test.go words - added questions and quotes Jan 25, 2019

README.md

alt text

gofakeit Go Report Card Build Status codecov.io GoDoc license

Random data generator written in go

Buy Me A Coffee

Features

  • Every function has an example and a benchmark, see benchmarks
  • Zero dependencies
  • Randomizes user defined structs
  • Numerous functions for regular use

120+ Functions!!!

If there is something that is generic enough missing from this package add an issue and let me know what you need. Most of the time i'll add it!

Seed

If you would like to ensure randomization on initial use be sure to seed it first

gofakeit.Seed(time.Now().UnixNano()) // or gofakeit.Seed(0)

Installation

go get github.com/brianvoe/gofakeit/v4

Example

import "github.com/brianvoe/gofakeit/v4"

gofakeit.Seed(0)

gofakeit.Name() // Markus Moen
gofakeit.Email() // alaynawuckert@kozey.biz
gofakeit.Phone() // (570)245-7485
gofakeit.BS() // front-end
gofakeit.BeerName() // Duvel
gofakeit.Color() // MediumOrchid
gofakeit.Company() // Moen, Pagac and Wuckert
gofakeit.CreditCardNumber() // 4287271570245748
gofakeit.HackerPhrase() // Connecting the array won't do anything, we need to generate the haptic COM driver!
gofakeit.JobTitle() // Director
gofakeit.Password(true, true, true, true, true, 32) // WV10MzLxq2DX79w1omH97_0ga59j8!kj
gofakeit.CurrencyShort() // USD
// See full list below

Example Struct

import "github.com/brianvoe/gofakeit/v4"

// Create structs with random injected data
type Foo struct {
	Bar     string
	Int     int
	Pointer *int
	Name    string  `fake:"{person.first}"`
	Skip    *string `fake:"skip"` // Set to "skip" to not generate data for
}

// Pass your struct as a pointer
var f Foo
gofakeit.Struct(&f)

fmt.Printf("f.Bar:%s\n", f.Bar) // f.Bar:hrukpttuezptneuvunh
fmt.Printf("f.Int:%d\n", f.Int) // f.Int:-7825289004089916589
fmt.Printf("f.Pointer:%d\n", *f.Pointer) // f.Pointer:-343806609094473732
fmt.Printf("f.Name:%v\n", f.Name) // f.Name:fred
fmt.Printf("f.Skip:%v\n", f.Skip) // f.Skip:<nil>

Person

Person() *PersonInfo
Name() string
NamePrefix() string
NameSuffix() string
FirstName() string
LastName() string
Gender() string
SSN() string
Contact() *ContactInfo
Email() string
Phone() string
PhoneFormatted() string

Auth

Username() string
Password(lower bool, upper bool, numeric bool, special bool, space bool, num int) string

Address

Address() *AddressInfo
City() string
Country() string
CountryAbr() string
State() string
StateAbr() string
Street() string
StreetName() string
StreetNumber() string
StreetPrefix() string
StreetSuffix() string
Zip() string
Latitude() float64
LatitudeInRange(min, max float64) (float64, error)
Longitude() float64
LongitudeInRange(min, max float64) (float64, error)

Beer

BeerAlcohol() string
BeerBlg() string
BeerHop() string
BeerIbu() string
BeerMalt() string
BeerName() string
BeerStyle() string
BeerYeast() string

Cars

Vehicle() *VehicleInfo
CarMaker() string
CarModel() string
VehicleType() string
FuelType() string
TransmissionGearType() string

Words

Word() string
Sentence(wordCount int) string
Paragraph(paragraphCount int, sentenceCount int, wordCount int, separator string) string
Question() string
Quote() string

Misc

Struct(v interface{})
Map() map[string]interface{}
Generate() string
Bool() bool
UUID() string

Colors

Color() string
HexColor() string
RGBColor() string
SafeColor() string

Internet

URL() string
ImageURL(width int, height int) string
DomainName() string
DomainSuffix() string
IPv4Address() string
IPv6Address() string
StatusCode() string
SimpleStatusCode() int
LogLevel(logType string) string
HTTPMethod() string
UserAgent() string
ChromeUserAgent() string
FirefoxUserAgent() string
OperaUserAgent() string
SafariUserAgent() string

Date/Time

Date() time.Time
DateRange(start, end time.Time) time.Time
NanoSecond() int
Second() int
Minute() int
Hour() int
Month() string
Day() int
WeekDay() string
Year() int
TimeZone() string
TimeZoneAbv() string
TimeZoneFull() string
TimeZoneOffset() float32

Payment

Price(min, max float64) float64
CreditCard() *CreditCardInfo
CreditCardCvv() string
CreditCardExp() string
CreditCardNumber() int
CreditCardNumberLuhn() int
CreditCardType() string
Currency() *CurrencyInfo
CurrencyLong() string
CurrencyShort() string

Company

BS() string
BuzzWord() string
Company() string
CompanySuffix() string
Job() *JobInfo
JobDescriptor() string
JobLevel() string
JobTitle() string

Hacker

HackerAbbreviation() string
HackerAdjective() string
HackerIngverb() string
HackerNoun() string
HackerPhrase() string
HackerVerb() string

Hipster

HipsterWord() string
HipsterSentence(wordCount int) string
HipsterParagraph(paragraphCount int, sentenceCount int, wordCount int, separator string) string

Animal

PetName() string
Animal() string
AnimalType() string
FarmAnimal() string
Cat() string
Dog() string

Languages

Language() string
LanguageAbbreviation() string
ProgrammingLanguage() string
ProgrammingLanguageBest() string

File

Extension() string
MimeType() string

Numbers

Number(min int, max int) int
Numerify(str string) string
Int8() int8
Int16() int16
Int32() int32
Int64() int64
Uint8() uint8
Uint16() uint16
Uint32() uint32
Uint64() uint64
Float32() float32
Float32Range(min, max float32) float32
Float64() float64
Float64Range(min, max float64) float64
ShuffleInts(a []int)

String

Digit() string
Letter() string
Lexify(str string) string
RandString(a []string) string
ShuffleStrings(a []string)
You can’t perform that action at this time.