Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Dec 8, 2022. It is now read-only.
/fakerPublic archive

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

License

NotificationsYou must be signed in to change notification settings

bxcodec/faker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

136 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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.


Docs

Struct Data Fake Generator

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

Build StatuscodecovGo Report CardLicenseGo.Dev

Index

Support

You can file anIssue.See documentation inGo.Dev

Getting Started

Download

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

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 skipfaker:"-" on your private fields.
  • It does not support theinterface{} data type. How could we generate anything without knowing its data type?
  • It does not support themap[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 usefaker, 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
  • Theoneof tag currently only supportsstring, theint types, and bothfloat32 &float64. Further support is coming soon (i.e. hex numbers, etc). Seeexample 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 repositoryhttps://github.com/go-faker/faker

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Contributors46


[8]ページ先頭

©2009-2026 Movatter.jp