GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - bxcodec/faker: Go (Golang) Fake Data Generator for Struct. [Notes]This repository is archived, moved to the new repository https://github.com/go-faker/faker

This repository was archived by the owner on Dec 8, 2022. It is now read-only.
BranchesTags
Open more actions menu

Latest commit

 

History

136 Commits
136 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
misc/makefile
misc/makefile
 
 
pkg
pkg
 
 
.gitignore
.gitignore
 
 
.golangci.yaml
.golangci.yaml
 
 
.travis.yml
.travis.yml
 
 
LICENSE
LICENSE
 
 
Makefile
Makefile
 
 
README.md
README.md
 
 
address.go
address.go
 
 
address_test.go
address_test.go
 
 
datetime.go
datetime.go
 
 
datetime_test.go
datetime_test.go
 
 
example_custom_faker_test.go
example_custom_faker_test.go
 
 
example_single_fake_data_test.go
example_single_fake_data_test.go
 
 
example_with_tags_lang_test.go
example_with_tags_lang_test.go
 
 
example_with_tags_lenbounds_test.go
example_with_tags_lenbounds_test.go
 
 
example_with_tags_slicelength_test.go
example_with_tags_slicelength_test.go
 
 
example_with_tags_test.go
example_with_tags_test.go
 
 
example_with_tags_unique_test.go
example_with_tags_unique_test.go
 
 
example_without_tag_test.go
example_without_tag_test.go
 
 
faker.go
faker.go
 
 
faker_test.go
faker_test.go
 
 
go.mod
go.mod
 
 
go.sum
go.sum
 
 
internet.go
internet.go
 
 
internet_test.go
internet_test.go
 
 
lorem.go
lorem.go
 
 
lorem_test.go
lorem_test.go
 
 
payment.go
payment.go
 
 
payment_test.go
payment_test.go
 
 
person.go
person.go
 
 
person_test.go
person_test.go
 
 
phone.go
phone.go
 
 
phone_test.go
phone_test.go
 
 
price.go
price.go
 
 
price_test.go
price_test.go
 
 
random_source.go
random_source.go
 
 
random_source_test.go
random_source_test.go
 
 
tag_argument_extractor.go
tag_argument_extractor.go
 
 
tag_argument_extractor_test.go
tag_argument_extractor_test.go
 
 
uuid.go
uuid.go
 
 
uuid_test.go
uuid_test.go
 
 

Repository files navigation

Important Notes

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.


Docs

faker

Struct Data Fake Generator

Faker will generate you a fake data based on your Struct.

Build Status codecov Go Report Card License Go.Dev

Index

  • Support
  • Getting Started
  • Example
  • Limitation
  • Contribution

Support

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

Getting Started

Download

go get -u github.com/bxcodec/faker/v4

Example


  • Using Struct's tag:
    • basic tags: example_with_tags_test.go
    • length and bounds: example_with_tags_lenbounds_test.go
    • language: example_with_tags_lang_test.go
    • unique: example_with_tags_unique_test.go
    • slice length: example_with_tags_slicelength_test.go
  • 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

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.

About

Go (Golang) Fake Data Generator for Struct. [Notes]This repository is archived, moved to the new repository https://github.com/go-faker/faker

pkg.go.dev/github.com/bxcodec/faker/v4

Topics

dummy-datadummy-data-generatorfake-datafakergeneratorgogolanghactoberfestmock-datastructtesting-tools

Resources

Readme
MIT license
Activity

Stars

2.1k stars

Watchers

2 watching

Forks

144 forks
Report repository

Releases

Sponsor this project

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.