Coder Social home page Coder Social logo

trendingtechnology / gofakeit Goto Github PK

View Code? Open in Web Editor NEW

This project forked from brianvoe/gofakeit

0.0 0.0 0.0 337 KB

Random fake data generator written in go

Home Page: https://godoc.org/github.com/brianvoe/gofakeit

License: MIT License

Go 100.00%

gofakeit's Introduction

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() // [email protected]
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.Skip: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
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
StatusCode() string
Street() string
StreetName() string
StreetNumber() string
StreetPrefix() string
StreetSuffix() string
Zip() string
Latitude() float64
LatitudeInRange() (float64, error)
Longitude() float64
LongitudeInRange() (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
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

Languages

Language() string
LanguageAbbreviation() string
ProgrammingLanguage() 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)

gofakeit's People

Contributors

bgadrian avatar brianvoe avatar bvoelker avatar calvernaz avatar cpbarker avatar hbagdi avatar luiz-n avatar mingrammer avatar moul avatar smt923 avatar stefanb avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.