Back to rankings

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

generatorfakergostructdummy-datadummy-data-generatorfake-datamock-datatesting-toolsgolanghactoberfest
Star Growth
Stars
2.1k
Forks
145
Weekly Growth
Issues
24
1k2k
Jun 2017Jun 2020Jul 2023Jul 2026
ArtifactsGo Modulesgo get github.com/bxcodec/faker
README

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

You can file an Issue. See documentation in Go.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 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.

Related repositories
OpenAPITools/openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)

JavaMavenApache License 2.0rest-apirest-client
openapi-generator.tech
26.6k7.6k
rahuldkjain/github-profile-readme-generator

🚀 Generate GitHub profile README easily with the latest add-ons like visitors count, GitHub stats, etc using minimal UI.

TypeScriptnpmApache License 2.0githubreadme
rahuldkjain.github.io/github-profile-readme-generator
24.4k8.4k
jhipster/generator-jhipster

JHipster is a development platform to quickly generate, develop, & deploy modern web applications & microservice architectures.

TypeScriptnpmApache License 2.0angularspring-boot
jhipster.tech
22.4k4.2k
infinitered/ignite

Infinite Red's battle-tested React Native project boilerplate, along with a CLI, component/model generators, and more! 9 years of continuous development and counting.

TypeScriptnpmOtherclireact-native
infinite.red/ignite
19.9k1.5k
orhun/git-cliff

A highly customizable Changelog Generator that follows Conventional Commit specifications ⛰️

Rustcrates.ioApache License 2.0changeloggenerator
git-cliff.org
12k307
kefranabg/readme-md-generator

📄 CLI that generates beautiful README.md files

JavaScriptnpmMIT Licensereadmereadme-template
npmjs.com/package/readme-md-generator
11.1k1.4k
bchavez/Bogus

:card_index: A simple fake data generator for C#, F#, and VB.NET. Based on and ported from the famed faker.js.

C#Otherfakedata
9.7k542
yonaskolb/XcodeGen

A Swift command line tool for generating your Xcode project

SwiftMIT Licenseswiftxcode
8.6k888
TypeStrong/typedoc

Documentation generator for TypeScript projects.

TypeScriptnpmApache License 2.0typescriptdocumentation
typedoc.org
8.4k769
bestony/logoly

A Pornhub Flavour Logo Generator

JavaScriptnpmDo What The F*ck You Want To Public Licensevuelogo
logoly.pro
7.9k799
plopjs/plop

Consistency Made Simple

JavaScriptnpmMIT Licenseplopjavascript
plopjs.com
7.7k294
github-changelog-generator/github-changelog-generator

Automatically generate change log from your tags, issues, labels and pull requests on GitHub.

RubyRubyGemsMIT Licenserubylabels
7.5k845