Skip to content
Go (Golang) Fake Data Generator for Struct
Go Makefile
Branch: master
Clone or download

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
support/slice feat(faker): unique data generation (#77) Nov 15, 2019
.gitignore Optionally insert nils instead of empty slices and maps (#59) Feb 9, 2019
.golangci.yaml chore(linters): resolve linter and typos (#78) Nov 15, 2019
.travis.yml chore(go): update go version for testing in travis (#85) Jan 9, 2020
CustomFaker.md chore: update examples (#88) Feb 17, 2020
LICENSE Initial commit Jun 22, 2017
Makefile chore(linters): resolve linter and typos (#78) Nov 15, 2019
README.md README.md: fix a typo & formatting (#79) Jan 9, 2020
SingleFakeData.md chore: update examples (#88) Feb 17, 2020
WithStructTag.md chore: update examples (#88) Feb 17, 2020
WithoutTag.md chore: update examples (#88) Feb 17, 2020
address.go feat(faker): unique data generation (#77) Nov 15, 2019
address_test.go feat(faker): open the faker core function to be able accessed from ex… Mar 8, 2019
datetime.go feat(faker): unique data generation (#77) Nov 15, 2019
datetime_test.go feat(faker): open the faker core function to be able accessed from ex… Mar 8, 2019
faker.go feat(error): extend error messages for bad tag's name (#80) Jan 9, 2020
faker_test.go chore(linters): resolve linter and typos (#78) Nov 15, 2019
go.mod fix(skip-tag): skip tag does not really skip the value but reset it. (#… May 7, 2019
go.sum feat(faker): open the faker core function to be able accessed from ex… Mar 8, 2019
internet.go chore(linters): resolve linter and typos (#78) Nov 15, 2019
internet_test.go feat(faker): open the faker core function to be able accessed from ex… Mar 8, 2019
lorem.go feat(faker): unique data generation (#77) Nov 15, 2019
lorem_test.go feat(faker): unique data generation (#77) Nov 15, 2019
payment.go feat(faker): unique data generation (#77) Nov 15, 2019
payment_test.go feat(faker): open the faker core function to be able accessed from ex… Mar 8, 2019
person.go feat(faker): unique data generation (#77) Nov 15, 2019
person_test.go feat(faker): open the faker core function to be able accessed from ex… Mar 8, 2019
phone.go feat(faker): unique data generation (#77) Nov 15, 2019
phone_test.go feat(faker): open the faker core function to be able accessed from ex… Mar 8, 2019
price.go feat(faker): unique data generation (#77) Nov 15, 2019
price_test.go chore(typos): fix typos #73 Nov 15, 2019
uuid.go feat(faker): unique data generation (#77) Nov 15, 2019
uuid_test.go feat(faker): open the faker core function to be able accessed from ex… Mar 8, 2019

README.md

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/v3

Example


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 be PUBLIC.
Support Only For :

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

Limitation


Unfortunately this library has some limitation

  • It does not support private fields. Make sure your structs fields you intend to generate fake data for are public, it would otherwise trigger a panic. You can however omit fields using a tag skip faker:"-" on your private fields.
  • It does not support the interface{} data type. How could we generate anything without knowing its data type?
  • It does not support the map[interface{}]interface{}, map[any_type]interface{} & map[interface{}]any_type data types. Once again, we cannot generate values for an unknown data type.
  • Custom types are not fully supported. However some custom types are already supported: we are still investigating how to do this the correct way. For now, if you use faker, it's safer not to use any custom types in order to avoid panics.

Contribution


To contrib to this project, you can open a PR or an issue.

You can’t perform that action at this time.