Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork147
Go (Golang) Fake Data Generator for Struct. [Notes]This repository is archived, moved to the new repositoryhttps://github.com/go-faker/faker
License
bxcodec/faker
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
This repository has been archived, andmoved to the new repository herehttps://github.com/go-faker/fakerFurther 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 anIssue.See documentation inGo.Dev
go get -u github.com/bxcodec/faker/v4
- Using Struct's tag:
- Custom Struct's tag (define your own faker data):example_custom_faker_test.go
- Without struct's tag:example_without_tag_test.go
- Single Fake Data Function:example_single_fake_data_test.go
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&[]int64bool&[]boolstring&[]stringfloat32,float64,[]float32&[]float64time.Time&[]time.Time- Nested Struct Field
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_typedata 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. - Some extra custom types can be supported IF AND ONLY IF extended withAddProvider() please seeexample
- The
oneoftag currently only supportsstring, theinttypes, and bothfloat32&float64. Further support is coming soon (i.e. hex numbers, etc). Seeexample for usage.
To contrib to this project, you can open a PR or an issue.
About
Go (Golang) Fake Data Generator for Struct. [Notes]This repository is archived, moved to the new repositoryhttps://github.com/go-faker/faker
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Packages0
Uh oh!
There was an error while loading.Please reload this page.
