faker

package module
v2.0.1+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 22, 2019 License: MIT Imports: 13 Imported by: 44

README

Docs

faker

Struct Data Fake Generator

Faker will generate you a fake data based on your Struct.

Build Status codecov Go Report Card License GoDoc

Index

Support

You can file an Issue. See documentation in Godoc

Getting Started

Download
go get -u github.com/bxcodec/faker

Example

With Tag

Supported tag:

Internet :

  • Email
  • Mac address
  • Domain name
  • URL
  • UserName
  • IP Address (IPv4, IPv6 )
  • Password

Payment :

  • Credit Card Type (VISA, MASTERCARD, AMERICAN EXPRESS, DISCOVER)
  • Credit Card Number

Address :

  • Latitude and Longitude

Phone :

  • Phone number
  • Toll free phone number
  • E164PhoneNumber

Person :

  • Title male
  • Title female
  • FirstName
  • FirstName male
  • FirstName female
  • LastName
  • Name

DateTime :

  • UnixTime
  • Date
  • Time
  • MonthName
  • Year
  • DayOfWeek
  • DayOfMonth
  • Timestamp
  • Century
  • TimeZone
  • TimePeriod

Lorem :

  • Word
  • Sentence
  • Paragraph

Price :

  • Currency
  • Amount
  • Amount with Currency

UUID :

  • UUID Digit (32 bytes)
  • UUID Hyphenated (36 bytes)

Skip :

  • -

package main

import (
	"fmt"

	"github.com/bxcodec/faker"
)

// SomeStruct ...
type SomeStruct struct {
	Latitude           float32 `faker:"lat"`
	Longitude          float32 `faker:"long"`
	CreditCardNumber   string  `faker:"cc_number"`
	CreditCardType     string  `faker:"cc_type"`
	Email              string  `faker:"email"`
	IPV4               string  `faker:"ipv4"`
	IPV6               string  `faker:"ipv6"`
	Password           string  `faker:"password"`
	PhoneNumber        string  `faker:"phone_number"`
	MacAddress         string  `faker:"mac_address"`
	URL                string  `faker:"url"`
	UserName           string  `faker:"username"`
	ToolFreeNumber     string  `faker:"tool_free_number"`
	E164PhoneNumber    string  `faker:"e_164_phone_number"`
	TitleMale          string  `faker:"title_male"`
	TitleFemale        string  `faker:"title_female"`
	FirstName          string  `faker:"first_name"`
	FirstNameMale      string  `faker:"first_name_male"`
	FirstNameFemale    string  `faker:"first_name_female"`
	LastName           string  `faker:"last_name"`
	Name               string  `faker:"name"`
	UnixTime           int64   `faker:"unix_time"`
	Date               string  `faker:"date"`
	Time               string  `faker:"time"`
	MonthName          string  `faker:"month_name"`
	Year               string  `faker:"year"`
	DayOfWeek          string  `faker:"day_of_week"`
	DayOfMonth         string  `faker:"day_of_month"`
	Timestamp          string  `faker:"timestamp"`
	Century            string  `faker:"century"`
	TimeZone           string  `faker:"timezone"`
	TimePeriod         string  `faker:"time_period"`
	Word               string  `faker:"word"`
	Sentence           string  `faker:"sentence"`
	Paragraph          string  `faker:"paragraph"`
	Currency           string  `faker:"currency"`
	Amount             float64 `faker:"amount"`
	AmountWithCurrency string  `faker:"amount_with_currency"`
	UUIDHypenated	   string  `faker:"uuid_hyphenated"`
	UUID	           string  `faker:"uuid_digit"`
	Skip		   string  `faker:"-"`
}

func main() {

	a := SomeStruct{}
	err := faker.FakeData(&a)
	if err != nil {
		fmt.Println(err)
	}
	fmt.Printf("%+v", a)
	/*
		Output  :
		{
			Latitude: 81.12195
			Longitude: -84.38158
			CreditCardType: American Express
			CreditCardNumber: 373641309057568
			Email: mJBJtbv@OSAaT.ru
			IPV4: 99.23.42.63
			IPV6: 975c:fb2c:2133:fbdd:beda:282e:1e0a:ec7d
			Password: dfJdyHGuVkHBgnHLQQgpINApynzexnRpgIKBpiIjpTPOmNyMFb
			PhoneNumber: 792-153-4861
			MacAddress: cd:65:e1:d4:76:c6
			URL: https://www.oEuqqAY.org/QgqfOhd
			UserName: lVxELHS
			ToolFreeNumber: (777) 831-964572
			E164PhoneNumber: +724891571063
			TitleMale: Mr.
			TitleFemale: Queen
			FirstName: Whitney
			FirstNameMale: Kenny
			FirstNameFemale: Jana
			LastName: Rohan
			Name: Miss Casandra Kiehn
			UnixTime: 1197930901
			Date: 1982-02-27
			Time: 03:10:25
			MonthName: February
			Year: 1996
			DayOfWeek: Sunday
			DayOfMonth: 20
			Timestamp: 1973-06-21 14:50:46
			Century: IV
			TimeZone: Canada/Eastern
			TimePeriod: AM
			Word: nesciunt
			Sentence: Consequatur perferendis aut sit voluptatem accusantium.
			Paragraph: Aut consequatur sit perferendis accusantium voluptatem. Accusantium perferendis consequatur voluptatem sit aut. Aut sit accusantium consequatur voluptatem perferendis. Perferendis voluptatem aut accusantium consequatur sit.
			Currency: IRR,
			Amount: 88.990000,
			AmountWithCurrency: XBB 49257.100000,
			UUIDHypenated: 8f8e4463-9560-4a38-9b0c-ef24481e4e27,
			UUID: 90ea6479fd0e4940af741f0a87596b73,
			Skip:
		}
	*/
}

Custom Generator Provider

You can also add your own generator function to your own defined tags. See example below

type Gondoruwo struct {
	Name       string
	Locatadata int
}

type Sample struct {
	ID                 int64     `faker:"customIdFaker"`
	Gondoruwo          Gondoruwo `faker:"gondoruwo"`
	Danger             string    `faker:"danger"`
}

func CustomGenerator() {
	faker.AddProvider("customIdFaker", func(v reflect.Value) (interface{}, error) {
		 return int64(43), nil
	})
	faker.AddProvider("danger", func(v reflect.Value) (interface{}, error) {
		return "danger-ranger", nil
	})

	faker.AddProvider("gondoruwo", func(v reflect.Value) (interface{}, error) {
		obj := Gondoruwo{
			Name:       "Power",
			Locatadata: 324,
		}
		return obj, nil
	})
}

func main() { 
	CustomGenerator()
	var sample Sample
	faker.FakeData(&sample)
	fmt.Printf("%+v", sample)
}

Results:

{ID:43 Gondoruwo:{Name:Power Locatadata:324} Danger:danger-ranger}

Without Tag

You also can use faker to generate your structs data randomly without any tag. And it will fill the data based on its data-type.


package main

import (
	"fmt"

	"github.com/bxcodec/faker"
)

type SomeStruct struct {
	Int      int
	Int8     int8
	Int16    int16
	Int32    int32
	Int64    int64
	String   string
	Bool     bool
	SString  []string
	SInt     []int
	SInt8    []int8
	SInt16   []int16
	SInt32   []int32
	SInt64   []int64
	SFloat32 []float32
	SFloat64 []float64
	SBool    []bool
	Struct   AStruct
}
type AStruct struct {
	Number        int64
	Height        int64
	AnotherStruct BStruct
}

type BStruct struct {
	Image string
}

func main() {

	a := SomeStruct{}
	err := faker.FakeData(&a)
	if err != nil {
		fmt.Println(err)
	}
	fmt.Printf("%+v", a)
	/*
		Output:
		{
		    Int:5231564546548329
		    Int8:52
		    Int16:8
		    Int32:2046951236
		    Int64:1486554863682234423
		    String:ELIQhSfhHmWxyzRPOTNblEQsp
		    Bool:false
		    SString:[bzYwplRGUAXPwatnpVMWSYjep zmeuJVGHHgmIsuyWmLJnDmbTI FqtejCwoDyMBWatoykIzorCJZ]
		    SInt:[11661230973193 626062851427 12674621422454 5566279673347]
		    SInt8:[12 2 58 22 11 66 5 88]
		    SInt16:[29295225 8411281 69902706328]
		    SInt32:[60525685140 2733640366211 278043484637 5167734561481]
		    SInt64:[81684520429188374184 9917955420365482658170 996818723778286568 163646873275501565]
		    SFloat32:[0.556428 0.7692596 0.6779895 0.29171365 0.95445055]
		    SFloat64:[0.44829454895586585 0.5495675898536803 0.6584538253883265]
		    SBool:[true false true false true true false]
		    Struct:{
		        Number:1
		        Height:26
		        AnotherStruct:{
		            Image:RmmaaHkAkrWHldVbBNuQSKlRb
		        }
		    }
		}
	*/
}

DEMO

Example to use Faker

Benchmark

Bench To Generate Fake Data

Without Tag
BenchmarkFakerDataNOTTagged-4             500000              3049 ns/op             488 B/op         20 allocs/op
Using Tag
 BenchmarkFakerDataTagged-4                100000             17470 ns/op             380 B/op         26 allocs/op
MUST KNOW

The Struct Field must PUBLIC.
Support Only For :

  • int int8 int16 int32 int64
  • []int []int8 []int16 []int32 []int64
  • bool []bool
  • string []string
  • float32 float64 []float32 []float64
  • Nested Struct Field
  • time.Time []time.Time

Limitation

Unfortunately this library has some limitation

  • Not support for private field. Just make sure your field's struct is public. If not, it will throw panic error. You can avoid panic using tag skip faker:"-" in the private field.
  • Not support for interface{} data type. How we can generate if we don't know what is the data type?
  • Not support for map[interface{}]interface{}, map[any_type]interface{}, map[interface{}]any_type. Still, it's about interface. We can't give you something if we don't know what really you want.
  • Not fully support for custom type, but a few custom type already supported, still investigating how to do this in the correct ways. For now, if you use faker, it's safer not to use any custom type to avoid panic.

Contribution

To contrib on this project, you can make a PR or just an issue.

Maintainer

Documentation

Index

Constants

View Source
const (
	BaseDate   = "2006-01-02"
	Time       = "15:04:05"
	Month      = "January"
	Year       = "2006"
	Day        = "Monday"
	DayOfMonth = "_2"
	TimePeriod = "PM"
)

These example values must use the reference time "Mon Jan 2 15:04:05 MST 2006" as described at https://gobyexample.com/time-formatting-parsing

View Source
const (
	ID                 = "uuid_digit"
	HyphenatedID       = "uuid_hyphenated"
	Email              = "email"
	MacAddress         = "mac_address"
	DomainName         = "domain_name"
	UserName           = "username"
	URL                = "url"
	IPV4               = "ipv4"
	IPV6               = "ipv6"
	PASSWORD           = "password"
	LATITUDE           = "lat"
	LONGITUDE          = "long"
	CreditCardNumber   = "cc_number"
	CreditCardType     = "cc_type"
	PhoneNumber        = "phone_number"
	TollFreeNumber     = "tool_free_number"
	E164PhoneNumber    = "e_164_phone_number"
	TitleMale          = "title_male"
	TitleFemale        = "title_female"
	FirstName          = "first_name"
	FirstNameMale      = "first_name_male"
	FirstNameFemale    = "first_name_female"
	LastName           = "last_name"
	NAME               = "name"
	UnixTime           = "unix_time"
	DATE               = "date"
	TIME               = "time"
	MonthName          = "month_name"
	YEAR               = "year"
	DayOfWeek          = "day_of_week"
	DayOfMonthTag      = "day_of_month"
	TIMESTAMP          = "timestamp"
	CENTURY            = "century"
	TIMEZONE           = "timezone"
	TimePeriodTag      = "time_period"
	WORD               = "word"
	SENTENCE           = "sentence"
	PARAGRAPH          = "paragraph"
	Currency           = "currency"
	Amount             = "amount"
	AmountWithCurrency = "amount_with_currency"
	SKIP               = "-"
)

Supported tags

Variables

View Source
var (
	ErrUnsupportedKindPtr  = "Unsupported kind: %s Change Without using * (pointer) in Field of %s"
	ErrUnsupportedKind     = "Unsupported kind: %s"
	ErrValueNotPtr         = "Not a pointer value"
	ErrTagNotSupported     = "Tag unsupported"
	ErrTagAlreadyExists    = "Tag exists"
	ErrMoreArguments       = "Passed more arguments than is possible : (%d)"
	ErrNotSupportedPointer = "Use sample:=new(%s)\n faker.FakeData(sample) instead"
)

Generic Error Messages for tags

ErrUnsupportedKindPtr: Error when get fake from ptr
ErrUnsupportedKind: Error on passing unsupported kind
ErrValueNotPtr: Error when value is not pointer
ErrTagNotSupported: Error when tag is not supported
ErrTagAlreadyExists: Error when tag exists and call AddProvider
ErrMoreArguments: Error on passing more arguments
ErrNotSupportedPointer: Error when passing unsupported pointer

Functions

func AddProvider added in v1.5.0

func AddProvider(tag string, provider TaggedFunction) error

AddProvider extend faker with tag to generate fake data with specified custom algoritm

func FakeData

func FakeData(a interface{}) error

FakeData is the main function. Will generate a fake data based on your struct. You can use this for automation testing, or anything that need automated data. You don't need to Create your own data for your testing.

func RandomInt added in v1.3.0

func RandomInt(parameters ...int) (p []int, err error)

RandomInt Get three parameters , only first mandatory and the rest are optional

If only set one parameter :  This means the minimum number of digits and the total number
If only set two parameters : First this is min digit and second max digit and the total number the difference between them
If only three parameters: the third argument set Max count Digit

func RandomUnixTime added in v1.3.0

func RandomUnixTime() int64

RandomUnixTime is a helper function returning random Unix time

func SetAddress added in v1.3.0

func SetAddress(net Addresser)

SetAddress sets custom Address

func SetDataFaker added in v1.3.0

func SetDataFaker(d DataFaker)

SetDataFaker sets Custom data in lorem

func SetDateTimer added in v1.3.0

func SetDateTimer(d DateTimer)

SetDateTimer sets custom date time

func SetDowser added in v1.3.0

func SetDowser(d Dowser)

SetDowser sets custom Dowsers of Person names

func SetNetwork added in v1.3.0

func SetNetwork(net Networker)

SetNetwork sets custom Network

func SetPayment added in v1.3.0

func SetPayment(p Render)

SetPayment set custom Network

func SetPhoner added in v1.3.0

func SetPhoner(p Phoner)

SetPhoner sets custom Phoner

func SetPrice added in v1.5.0

func SetPrice(p Money)

SetPrice sets custom Money

Types

type Address added in v1.3.0

type Address struct{}

Address struct

func (Address) Latitude added in v1.3.0

func (i Address) Latitude(v reflect.Value) (interface{}, error)

Latitude sets latitude of the address

func (Address) Longitude added in v1.3.0

func (i Address) Longitude(v reflect.Value) (interface{}, error)

Longitude sets longitude of the address

type Addresser added in v1.3.0

type Addresser interface {
	Latitude(v reflect.Value) (interface{}, error)
	Longitude(v reflect.Value) (interface{}, error)
}

Addresser is logical layer for Address

func GetAddress added in v1.3.0

func GetAddress() Addresser

GetAddress returns a new Addresser interface of Address

type DataFaker added in v1.3.0

type DataFaker interface {
	Word(v reflect.Value) (interface{}, error)
	Sentence(v reflect.Value) (interface{}, error)
	Paragraph(v reflect.Value) (interface{}, error)
}

DataFaker generates randomized Words, Sentences and Paragraphs

func GetLorem added in v1.3.0

func GetLorem() DataFaker

GetLorem returns a new DataFaker interface of Lorem struct

type DateTime added in v1.3.0

type DateTime struct {
}

DateTime struct

func (DateTime) Century added in v1.3.0

func (d DateTime) Century(v reflect.Value) (interface{}, error)

Century returns a random century

func (DateTime) Date added in v1.3.0

func (d DateTime) Date(v reflect.Value) (interface{}, error)

Date formats DateTime using example BaseDate const

func (DateTime) DayOfMonth added in v1.3.0

func (d DateTime) DayOfMonth(v reflect.Value) (interface{}, error)

DayOfMonth formats DateTime using example DayOfMonth const

func (DateTime) DayOfWeek added in v1.3.0

func (d DateTime) DayOfWeek(v reflect.Value) (interface{}, error)

DayOfWeek formats DateTime using example Day const

func (DateTime) MonthName added in v1.3.0

func (d DateTime) MonthName(v reflect.Value) (interface{}, error)

MonthName formats DateTime using example Month const

func (DateTime) Time added in v1.3.0

func (d DateTime) Time(v reflect.Value) (interface{}, error)

Time formats DateTime using example Time const

func (DateTime) TimePeriod added in v1.3.0

func (d DateTime) TimePeriod(v reflect.Value) (interface{}, error)

TimePeriod formats DateTime using example TimePeriod const

func (DateTime) TimeZone added in v1.3.0

func (d DateTime) TimeZone(v reflect.Value) (interface{}, error)

TimeZone returns a random timezone

func (DateTime) Timestamp added in v1.3.0

func (d DateTime) Timestamp(v reflect.Value) (interface{}, error)

Timestamp formats DateTime using example Timestamp const

func (DateTime) UnixTime added in v1.3.0

func (d DateTime) UnixTime(v reflect.Value) (interface{}, error)

UnixTime get unix time

func (DateTime) Year added in v1.3.0

func (d DateTime) Year(v reflect.Value) (interface{}, error)

Year formats DateTime using example Year const

type DateTimer added in v1.3.0

type DateTimer interface {
	UnixTime(v reflect.Value) (interface{}, error)
	Date(v reflect.Value) (interface{}, error)
	Time(v reflect.Value) (interface{}, error)
	MonthName(v reflect.Value) (interface{}, error)
	Year(v reflect.Value) (interface{}, error)
	DayOfWeek(v reflect.Value) (interface{}, error)
	DayOfMonth(v reflect.Value) (interface{}, error)
	Timestamp(v reflect.Value) (interface{}, error)
	Century(v reflect.Value) (interface{}, error)
	TimeZone(v reflect.Value) (interface{}, error)
	TimePeriod(v reflect.Value) (interface{}, error)
}

A DateTimer contains random Time generators, returning time string in certain particular format

func GetDateTimer added in v1.3.0

func GetDateTimer() DateTimer

GetDateTimer returns a new DateTimer interface of DateTime

type Dowser added in v1.3.0

type Dowser interface {
	TitleMale(v reflect.Value) (interface{}, error)
	TitleFeMale(v reflect.Value) (interface{}, error)
	FirstName(v reflect.Value) (interface{}, error)
	FirstNameMale(v reflect.Value) (interface{}, error)
	FirstNameFemale(v reflect.Value) (interface{}, error)
	LastName(v reflect.Value) (interface{}, error)
	Name(v reflect.Value) (interface{}, error)
}

Dowser provides interfaces to generate random logical Names with their initials

func GetPerson added in v1.3.0

func GetPerson() Dowser

GetPerson returns a new Dowser interface of Person struct

type Identifier

type Identifier interface {
	Digit(v reflect.Value) (interface{}, error)
	Hyphenated(v reflect.Value) (interface{}, error)
}

Identifier ...

func GetIdentifier

func GetIdentifier() Identifier

GetIdentifier returns a new Identifier

type Internet added in v1.3.0

type Internet struct{}

Internet struct

func (Internet) DomainName added in v1.3.0

func (internet Internet) DomainName(v reflect.Value) (interface{}, error)

DomainName generates random domain name

func (Internet) Email added in v1.3.0

func (internet Internet) Email(v reflect.Value) (interface{}, error)

Email generates random email id

func (Internet) IPv4 added in v1.5.0

func (internet Internet) IPv4(v reflect.Value) (interface{}, error)

IPv4 generates random IPv4 address

func (Internet) IPv6 added in v1.5.0

func (internet Internet) IPv6(v reflect.Value) (interface{}, error)

IPv6 generates random IPv6 address

func (Internet) MacAddress added in v1.3.0

func (internet Internet) MacAddress(v reflect.Value) (interface{}, error)

MacAddress generates random MacAddress

func (Internet) Password added in v1.3.0

func (internet Internet) Password(v reflect.Value) (interface{}, error)

Password returns a hashed password

func (Internet) URL added in v1.5.0

func (internet Internet) URL(v reflect.Value) (interface{}, error)

URL generates random URL standardised in urlFormats const

func (Internet) UserName added in v1.3.0

func (internet Internet) UserName(v reflect.Value) (interface{}, error)

UserName generates random username

type Lorem added in v1.3.0

type Lorem struct {
}

Lorem struct

func (Lorem) Paragraph added in v1.5.0

func (l Lorem) Paragraph(v reflect.Value) (interface{}, error)

Paragraph returns a series of sentences as a paragraph using the wordList const

func (Lorem) Sentence added in v1.3.0

func (l Lorem) Sentence(v reflect.Value) (interface{}, error)

Sentence returns a sentence using the wordList const

func (Lorem) Word added in v1.3.0

func (l Lorem) Word(v reflect.Value) (interface{}, error)

Word returns a word from the wordList const

type Money added in v1.5.0

type Money interface {
	Currency(v reflect.Value) (interface{}, error)
	Amount(v reflect.Value) (interface{}, error)
	AmountWithCurrency(v reflect.Value) (interface{}, error)
}

Money provides an interface to generate a custom price with or without a random currency code

func GetPrice added in v1.5.0

func GetPrice() Money

GetPrice returns a new Money interface of Price struct

type Networker added in v1.3.0

type Networker interface {
	Email(v reflect.Value) (interface{}, error)
	MacAddress(v reflect.Value) (interface{}, error)
	DomainName(v reflect.Value) (interface{}, error)
	URL(v reflect.Value) (interface{}, error)
	UserName(v reflect.Value) (interface{}, error)
	IPv4(v reflect.Value) (interface{}, error)
	IPv6(v reflect.Value) (interface{}, error)
	Password(v reflect.Value) (interface{}, error)
}

Networker is logical layer for Internet

func GetNetworker added in v1.3.0

func GetNetworker() Networker

GetNetworker returns a new Networker interface of Internet

type Payment added in v1.3.0

type Payment struct{}

Payment struct

func (Payment) CreditCardNumber added in v1.3.0

func (p Payment) CreditCardNumber(v reflect.Value) (interface{}, error)

CreditCardNumber generated credit card number according to the card number rules

func (Payment) CreditCardType added in v1.3.0

func (p Payment) CreditCardType(v reflect.Value) (interface{}, error)

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

type Person added in v1.3.0

type Person struct {
}

Person struct

func (Person) FirstName added in v1.5.0

func (p Person) FirstName(v reflect.Value) (interface{}, error)

FirstName retuns first names

func (Person) FirstNameFemale added in v1.3.0

func (p Person) FirstNameFemale(v reflect.Value) (interface{}, error)

FirstNameFemale retuns first names for females

func (Person) FirstNameMale added in v1.3.0

func (p Person) FirstNameMale(v reflect.Value) (interface{}, error)

FirstNameMale retuns first names for males

func (Person) LastName added in v1.3.0

func (p Person) LastName(v reflect.Value) (interface{}, error)

LastName returns last name

func (Person) Name added in v1.3.0

func (p Person) Name(v reflect.Value) (interface{}, error)

Name returns a random name

func (Person) TitleFeMale added in v1.3.0

func (p Person) TitleFeMale(v reflect.Value) (interface{}, error)

TitleFeMale generates random titles for females

func (Person) TitleMale added in v1.3.0

func (p Person) TitleMale(v reflect.Value) (interface{}, error)

TitleMale generates random titles for males

type Phone added in v1.3.0

type Phone struct {
}

Phone struct

func (Phone) E164PhoneNumber added in v1.3.0

func (p Phone) E164PhoneNumber(v reflect.Value) (interface{}, error)

E164PhoneNumber generates phone numbers of type: "+27113456789"

func (Phone) PhoneNumber added in v1.3.0

func (p Phone) PhoneNumber(v reflect.Value) (interface{}, error)

PhoneNumber generates phone numbers of type: "201-886-0269"

func (Phone) TollFreePhoneNumber added in v1.3.0

func (p Phone) TollFreePhoneNumber(v reflect.Value) (interface{}, error)

TollFreePhoneNumber generates phone numbers of type: "(888) 937-7238"

type Phoner added in v1.3.0

type Phoner interface {
	PhoneNumber(v reflect.Value) (interface{}, error)
	TollFreePhoneNumber(v reflect.Value) (interface{}, error)
	E164PhoneNumber(v reflect.Value) (interface{}, error)
}

Phoner serves overall tele-phonic contact generator

func GetPhoner added in v1.3.0

func GetPhoner() Phoner

GetPhoner serves as a constructor for Phoner interface

type Price added in v1.5.0

type Price struct {
}

Price struct

func (Price) Amount added in v1.5.0

func (p Price) Amount(v reflect.Value) (interface{}, error)

Amount returns a random floating price amount with a random precision of [1,2] up to (10**8 - 1)

func (Price) AmountWithCurrency added in v1.5.0

func (p Price) AmountWithCurrency(v reflect.Value) (interface{}, error)

AmountWithCurrency combines both price and currency together

func (Price) Currency added in v1.5.0

func (p Price) Currency(v reflect.Value) (interface{}, error)

Currency returns a random currency from currencies

type Render added in v1.3.0

type Render interface {
	CreditCardType(v reflect.Value) (interface{}, error)
	CreditCardNumber(v reflect.Value) (interface{}, error)
}

Render contains Whole Random Credit Card Generators with their types

func GetPayment added in v1.3.0

func GetPayment() Render

GetPayment returns a new Render interface of Payment struct

type TaggedFunction

type TaggedFunction func(v reflect.Value) (interface{}, error)

TaggedFunction ...

type UUID

type UUID struct{}

UUID struct

func (UUID) Digit

func (i UUID) Digit(v reflect.Value) (interface{}, error)

Digit returns a 32 bytes UUID

func (UUID) Hyphenated

func (i UUID) Hyphenated(v reflect.Value) (interface{}, error)

Hyphenated returns a 36 byte hyphenated UUID

Directories

Path Synopsis
support

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL