1
0
mirror of https://github.com/ManyakRus/crud_generator.git synced 2024-12-22 00:36:41 +02:00
crud_generator/vendor/github.com/bxcodec/faker/v3
Nikitin Aleksandr a6ea64ee3e новый
2023-10-24 18:03:04 +03:00
..
support/slice новый 2023-10-24 18:03:04 +03:00
.gitignore новый 2023-10-24 18:03:04 +03:00
.golangci.yaml новый 2023-10-24 18:03:04 +03:00
.travis.yml новый 2023-10-24 18:03:04 +03:00
address.go новый 2023-10-24 18:03:04 +03:00
datetime.go новый 2023-10-24 18:03:04 +03:00
faker.go новый 2023-10-24 18:03:04 +03:00
internet.go новый 2023-10-24 18:03:04 +03:00
LICENSE новый 2023-10-24 18:03:04 +03:00
lorem.go новый 2023-10-24 18:03:04 +03:00
Makefile новый 2023-10-24 18:03:04 +03:00
payment.go новый 2023-10-24 18:03:04 +03:00
person.go новый 2023-10-24 18:03:04 +03:00
phone.go новый 2023-10-24 18:03:04 +03:00
price.go новый 2023-10-24 18:03:04 +03:00
random_source.go новый 2023-10-24 18:03:04 +03:00
README.md новый 2023-10-24 18:03:04 +03:00
tag_argument_extractor.go новый 2023-10-24 18:03:04 +03:00
uuid.go новый 2023-10-24 18:03:04 +03:00

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 Go.Dev

Index

Support

You can file an Issue. See documentation in Godoc or in Go.Dev

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.
  • Some extra custom types can be supported IF AND ONLY IF extended with AddProvider() please see example
  • The 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.

Contribution


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