This repository has been archived, and moved to the new repository here https://github.com/go-faker/faker Further development and fixing will be happening in the new repository.
Struct Data Fake Generator
Faker will generate you a fake data based on your Struct.
You can file an Issue. See documentation in Go.Dev
go get -u github.com/bxcodec/faker/v4
Bench To Generate Fake Data
BenchmarkFakerDataNOTTagged-4 500000 3049 ns/op 488 B/op 20 allocs/op
BenchmarkFakerDataTagged-4 100000 17470 ns/op 380 B/op 26 allocs/op
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
Unfortunately this library has some limitation
faker:"-"
on your private fields.interface{}
data type. How could we generate anything without knowing its data type?map[interface{}]interface{}
, map[any_type]interface{}
& map[interface{}]any_type
data types. Once again, we cannot generate values for an unknown data type.faker
, it's safer not to use any custom types in order to avoid panics.oneof
tag currently only supports string
, the int
types, and both float32
& float64
. Further support is coming soon (i.e. hex numbers, etc). See example for usage.To contrib to this project, you can open a PR or an issue.