faker

package module
v0.0.0-...-367c84d Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2016 License: ISC Imports: 13 Imported by: 1

README

Build Status

gofaker

A package that generates fake data for GO


   _|_|_|            _|_|_|_|          _|                            
 _|          _|_|    _|        _|_|_|  _|  _|      _|_|    _|  _|_|  
 _|  _|_|  _|    _|  _|_|_|  _|    _|  _|_|      _|_|_|_|  _|_|      
 _|    _|  _|    _|  _|      _|    _|  _|  _|    _|        _|        
   _|_|_|    _|_|    _|        _|_|_|  _|    _|    _|_|_|  _|        


API

I am defining the API so This API is not stable and can be modified at any time.

Error handling

In this project I preferred panic instead of explicit error returns to keep the API clean and uniform. I think this project must be used by humans beings not by computers directly.

It is the same reason regexp.MustCompile panic instead of return an error.

Documentation

Index

Constants

View Source
const DefaultLocale = "en"

DefaultLocale is a constant that defines the default locale used in the default configuration.

Variables

This section is empty.

Functions

This section is empty.

Types

type AvatarOptions

type AvatarOptions struct {
	Size   string `default:"300"`
	Format string `default:".jpg"`
	Email  string
}

type EmailOptions

type EmailOptions struct {
	Name string
}

type Faker

type Faker struct {
	CurrentLocaleString string
	// contains filtered or unexported fields
}

Faker is the main API it also holds some config

func New

func New(options Options) (Faker, error)

New creates a new Faker with configuration passed in options

func NewDefault

func NewDefault() Faker

NewDefault creates a new Faker with default configuration

func NewForLocale

func NewForLocale(locale string) (Faker, error)

NewForLocale creates a new Faker with the specified locale and random seed

func (Faker) AMPM

func (f Faker) AMPM() string

AMPM returns a string AM or PM

func (Faker) Address

func (f Faker) Address() string

Address returns a full address

func (Faker) AppAuthor

func (f Faker) AppAuthor() string

AppAuthor returns a Author Name

func (Faker) AppName

func (f Faker) AppName() string

AppName returns a faker application name

func (Faker) AppVersion

func (f Faker) AppVersion() string

AppVersion returns a fake three digit version MAJOR MINOR and PATCH

func (Faker) AvatarImage

func (f Faker) AvatarImage() string

AvatarImage returns a Avatar image

func (Faker) AvatarImageWithOptions

func (f Faker) AvatarImageWithOptions(o AvatarOptions) string

AvatarImageWithOptions returns a AvatarImage image

func (Faker) BookAuthor

func (f Faker) BookAuthor() string

BookAuthor returns a fake author name

func (Faker) BookGenre

func (f Faker) BookGenre() string

BookGenre return a book genre name

func (Faker) BookISBN

func (f Faker) BookISBN() string

BookISBN returns a fake ISBN number The ISBN number is just an EAN13 code. See https://pt.wikipedia.org/wiki/International_Standard_Book_Number

func (Faker) BookPublisher

func (f Faker) BookPublisher() string

BookPublisher return a publisher company name

func (Faker) BookPublisherSuffix

func (f Faker) BookPublisherSuffix() string

BookPublisherSuffix return a publisher company suffix

func (Faker) BookTitle

func (f Faker) BookTitle() string

BookTitle returns a fake book title

func (Faker) Boolean

func (f Faker) Boolean() bool

Boolean returns a random true or false

func (Faker) BrazilCNPJ

func (f Faker) BrazilCNPJ() string

BrazilCNPJ Generates a valid Brazilian CNPJ See: https://pt.wikipedia.org/wiki/Cadastro_Nacional_da_Pessoa_Jur%C3%ADdica

func (Faker) BrazilCPF

func (f Faker) BrazilCPF() string

BrazilCPF Generates a valid Brazilian CPF See https://en.wikipedia.org/wiki/Cadastro_de_Pessoas_F%C3%ADsicas

func (Faker) Browser

func (f Faker) Browser() string

Browser returns a Browser name

func (Faker) BuildingNumber

func (f Faker) BuildingNumber() string

BuildingNumber return a number of a building

func (Faker) CMYK

func (f Faker) CMYK() color.CMYK

CMYK returns a valid CMYK color

func (Faker) CellPhoneNumber

func (f Faker) CellPhoneNumber() string

CellPhoneNumber returns a cellphone number

func (Faker) Century

func (f Faker) Century() string

Century returns a century from I to XXI

func (Faker) ChromeUserAgent

func (f Faker) ChromeUserAgent() string

func (Faker) City

func (f Faker) City() string

City returns a city name

func (Faker) CityPrefix

func (f Faker) CityPrefix() string

CityPrefix return a City Prefix

func (Faker) CitySuffix

func (f Faker) CitySuffix() string

CitySuffix return a City Suffix

func (Faker) ColorName

func (f Faker) ColorName() string

ColorName returns a name of a ColorName

func (f Faker) CompanyLogo() string

CompanyLogo returns a fake URL company name

func (Faker) CompanyName

func (f Faker) CompanyName() string

CompanyName returns a company name

func (Faker) CompanySuffix

func (f Faker) CompanySuffix() string

CompanySuffix returns a company suffix such as 'corp', 'LLC'

func (Faker) Country

func (f Faker) Country() string

Country returns a country name

func (Faker) CountryCode

func (f Faker) CountryCode() string

CountryCode returns a ISO Country code

func (Faker) CreditCardExpiryDate

func (f Faker) CreditCardExpiryDate() time.Time

CreditCardExpiryDate returns datetime after now

func (Faker) CreditCardNumber

func (f Faker) CreditCardNumber() string

CreditCardNumber returns a valid credit card number for a while I will not generate a full random valid card I will just return from a list of valid numbers

func (Faker) CreditCardType

func (f Faker) CreditCardType() string

CreditCardType returns a valid credit card type

func (Faker) CurrentLocale

func (f Faker) CurrentLocale() locales.Locale

CurrentLocale returns the current locale object

func (Faker) DateTime

func (f Faker) DateTime() time.Time

DateTime returns a random datetime The date is maximum 100 years from now in the past or in the future

func (Faker) DateTimeAfter

func (f Faker) DateTimeAfter(d time.Time) time.Time

DateTimeAfter returns a date after the specified date The date is maximum 100 years from now in the future

func (Faker) DateTimeBefore

func (f Faker) DateTimeBefore(d time.Time) time.Time

DateTimeBefore returns a date before the specified date The date is maximum 100 years from now in the past

func (Faker) DateTimeBetween

func (f Faker) DateTimeBetween(d1, d2 time.Time) time.Time

DateTimeBetween returns a date beetween d1 and d2

func (Faker) DayOfMonth

func (f Faker) DayOfMonth() int

DayOfMonth returns a day of the month between 1 and 31

func (Faker) DayOfWeek

func (f Faker) DayOfWeek() int

DayOfWeek returns a day of week between 1 and 7 where 1 is sunday

func (Faker) Decimal

func (f Faker) Decimal(len, places int) string

Decimal returns a decimal number with digits length and places decimal places length it will panic if len is less than 1

func (Faker) Digit

func (f Faker) Digit() int

Digit returns an positive int between 0 (inclusive) and 9 (inclusive)

func (Faker) DomainName

func (f Faker) DomainName() string

func (Faker) DomainSuffix

func (f Faker) DomainSuffix() string

DomainSuffix returns a domain suffix such as .com, .com.br

func (Faker) EAN13

func (f Faker) EAN13() string

EAN13 Generates a valid EAN13 bar code

func (Faker) Email

func (f Faker) Email() string

func (Faker) EmailWithOptions

func (f Faker) EmailWithOptions(o EmailOptions) string

func (Faker) FirefoxUserAgent

func (f Faker) FirefoxUserAgent() string

func (Faker) FirstName

func (f Faker) FirstName() string

FirstName returns a Male or Female first name

func (Faker) FreeEmail

func (f Faker) FreeEmail() string

FreeEmail returns a random safe email

func (Faker) FreeEmailWithOptions

func (f Faker) FreeEmailWithOptions(o EmailOptions) string

FreeEmailWithOptions returns a safe email with the options

func (Faker) Gender

func (f Faker) Gender() string

Gender returns a gender name

func (Faker) HexColor

func (f Faker) HexColor() string

HexColor returns a hexadecimal color, including alpha

func (Faker) Hexadecimal

func (f Faker) Hexadecimal(len int) string

Hexadecimal returns a alpha numeric with digits length it will panic if len is less than 1

func (Faker) IEUserAgent

func (f Faker) IEUserAgent() string

func (Faker) IPV4

func (f Faker) IPV4() string

func (Faker) IPV6

func (f Faker) IPV6() string

func (Faker) LastName

func (f Faker) LastName() string

LastName returns a Male or Female last name

func (Faker) Latitude

func (f Faker) Latitude() string

Latitude returns an earth latitude

func (Faker) Longitude

func (f Faker) Longitude() string

Longitude returns an earth longitude

func (Faker) MD5

func (f Faker) MD5() string

MD5 returns a random MD5 hexdigest See: https://en.wikipedia.org/wiki/MD5

func (Faker) MacAddress

func (f Faker) MacAddress() string

MacAddress returns a IEEE 802 MAC address

func (Faker) Month

func (f Faker) Month() int

Month returns a month between 1 and 12

func (Faker) Name

func (f Faker) Name() string

Name returns a Male or Female full name

func (Faker) NegativeNumber

func (f Faker) NegativeNumber() int

NegativeNumber returns an positive int between math.MinInt32 (inclusive) and -1 (inclusive)

func (Faker) Number

func (f Faker) Number(len int) int

Number returns a number with digits length it will panic if len is less than 1

func (Faker) NumberBetween

func (f Faker) NumberBetween(first, second int) int

NumberBetween returns a random integer between first (inclusive) and second (inclusive)

func (Faker) OS

func (f Faker) OS() string

OS returns a name of an Operating System

func (Faker) OperaUserAgent

func (f Faker) OperaUserAgent() string

func (Faker) Password

func (f Faker) Password() string

Password returns a 8 length password

func (Faker) PasswordWithOptions

func (f Faker) PasswordWithOptions(o PassWordOptions) string

PasswordWithOptions returns password defined by the options

func (Faker) PhoneAreaCode

func (f Faker) PhoneAreaCode() string

PhoneAreaCode returns an area code

func (Faker) PhoneExchangeCode

func (f Faker) PhoneExchangeCode() string

PhoneExchangeCode returns an exchange code

func (Faker) PhoneNumber

func (f Faker) PhoneNumber() string

PhoneNumber returns a phone number

func (Faker) PlaceholderImage

func (f Faker) PlaceholderImage() string

PlaceholderImage returns a Placeholder image

func (Faker) PlaceholderImageWithOptions

func (f Faker) PlaceholderImageWithOptions(o ImageOptions) string

PlaceholderImageWithOptions returns a Placeholder image

func (Faker) PositiveNumber

func (f Faker) PositiveNumber() int

PositiveNumber returns an positive int between 0 (inclusive) and math.MaxUint32 (inclusive)

func (Faker) ProductAdjective

func (f Faker) ProductAdjective() string

ProductAdjective returns a fake product adjective

func (Faker) ProductName

func (f Faker) ProductName() string

ProductName returns a fake product name

func (Faker) ProductPrice

func (f Faker) ProductPrice() float64

ProductPrice returns a fake product price between 0 and 5000

func (Faker) ProductSimpleName

func (f Faker) ProductSimpleName() string

ProductSimpleName returns a fake product name

func (Faker) ProgrammingLanguage

func (f Faker) ProgrammingLanguage() string

ProgrammingLanguage returns a name of a programming language

func (Faker) RFC3339

func (f Faker) RFC3339() string

RFC3339 returns a random date formatted as RFC3339

func (Faker) RGBA

func (f Faker) RGBA() color.RGBA

RGBA returns a valid RGBA color

func (Faker) SHA1

func (f Faker) SHA1() string

SHA1 returns a random SHA1 hexdigest See: https://en.wikipedia.org/wiki/SHA-1

func (Faker) SHA256

func (f Faker) SHA256() string

SHA256 returns a random SHA256 hexdigest See: https://en.wikipedia.org/wiki/SHA-2

func (Faker) SHA512

func (f Faker) SHA512() string

SHA512 returns a random SHA512 hexdigest See: https://en.wikipedia.org/wiki/SHA-2

func (Faker) SafariUserAgent

func (f Faker) SafariUserAgent() string

func (Faker) SecondaryAddress

func (f Faker) SecondaryAddress() string

SecondaryAddress returns a Secondary Address

func (Faker) Slug

func (f Faker) Slug() string

func (Faker) SlugWithOptions

func (f Faker) SlugWithOptions(o SlugOptions) string

func (Faker) State

func (f Faker) State() string

State returns a state name

func (Faker) StateAbbr

func (f Faker) StateAbbr() string

StateAbbr returns a state abbrewviation

func (Faker) StoreDepartment

func (f Faker) StoreDepartment() string

StoreDepartment returns a fake department name

func (Faker) StreetAddress

func (f Faker) StreetAddress() string

StreetAddress return a full street address

func (Faker) StreetName

func (f Faker) StreetName() string

StreetName return a street name

func (Faker) StreetSuffix

func (f Faker) StreetSuffix() string

StreetSuffix return a Street Suffix

func (Faker) TextEditor

func (f Faker) TextEditor() string

TextEditor returns a name of a TextEditor

func (Faker) TimeZone

func (f Faker) TimeZone() string

TimeZone returns TZ name

func (Faker) URL

func (f Faker) URL() string

func (Faker) URLWithOptions

func (f Faker) URLWithOptions(o URLOptions) string

func (Faker) UniversityName

func (f Faker) UniversityName() string

UniversityName returns a name of a University

func (Faker) UserAgent

func (f Faker) UserAgent() string

func (Faker) UserName

func (f Faker) UserName() string

UserName returns a username

func (Faker) UserNameWithOptions

func (f Faker) UserNameWithOptions(o UserNameOptions) string

UserNameWithOptions returns a username with the default options

func (Faker) WebFramework

func (f Faker) WebFramework() string

WebFramework returns a name of a WebFramework

func (Faker) Year

func (f Faker) Year() int

Year returns a year between 1500 and 2100

func (Faker) ZipCode

func (f Faker) ZipCode() string

ZipCode must return a zip code

type ImageOptions

type ImageOptions struct {
	Size   string `default:"300x300"`
	Format string `default:".jpg"`
}

type Options

type Options struct {
	Locale string
	Seed   int64
}

Options is used to pass configuration options to Faker

type PassWordOptions

type PassWordOptions struct {
	Length int  `default:"8"`
	Alpha  bool `default:"false"`
}

type SlugOptions

type SlugOptions struct {
	Value string
	Sep   string `default:"-"`
}

type URLOptions

type URLOptions struct {
	Protocol string `default:"http"`
	Domain   string `default:"example.com"`
	Path     string `default:"/"`
}

type UserNameOptions

type UserNameOptions struct {
	Name string
	Sep  string `default:"-"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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