gofakeit: A Go Library for Generating Fake Data Without Dependencies
Random fake data generator written in go
At a glance
- What is it?
- gofakeit is a zero-dependency Go package that produces random names, addresses, credit card numbers and struct fields, with a template tag system for shaping the output. It is the right tool when you need test fixtures in Go, and the wrong one when you need a standalone service or a database seeder.
- Who is it for?
- Adopt gofakeit if you are writing Go tests or fixtures and want fake values without pulling in a dependency tree; the MIT licence and zero-dependency design keep it easy to vendor. Skip it if you need a standalone fake-data server, a database seeder, or a non-Go language.
- Can I use it commercially?
- Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 12 days ago.
- What is it written in?
- Mainly Go, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on September 30, 2026, and from our analysis. They are not legal advice.
Editorial analysis
What gofakeit solves, and who should reach for it
Go tests need data. A struct with a Name string, an Email string and a Created time.Time will not exercise much if every fixture is the literal "test" repeated three times. gofakeit fills those fields with plausible values: gofakeit.Name() returns something like Markus Moen, gofakeit.Email() returns an address, and gofakeit.CreditCardNumber(nil) returns a number. The README lists 310+ functions, and the repository layout confirms the breadth: address.go, airline.go, animal.go, beer.go, book.go, car.go, celebrity.go, color.go, company.go, emoji.go, finance.go and food.go are all top-level files, each with a matching _test.go file.
The audience is Go developers writing unit tests, integration tests, seed scripts or demo data. It is not a service and not a command-line tool in the default install; it is a library you import. The README also points to two separate commands under cmd/, a command line tool and an HTTP server, but those are separate builds, not part of the library import.
One design decision is worth flagging early. The default global faker seeds itself with a cryptographically secure number, so two runs of the same test produce different data unless you call Seed explicitly. That is a reasonable default for demo data and a trap for tests that assert on exact output. The README is direct about this: every example in the repository sets the seed for testing purposes.
How the generator works: sources, fakers and the global rand set
gofakeit separates the random number source from the data functions. By default it uses math/rand/v2 PCG, a pseudo random generator, and the README states it is thread locked. That locking matters: the simple package-level calls like gofakeit.Name() are safe to call from multiple goroutines, and the repository includes concurrency_test.go, which suggests the maintainers treat concurrency as part of the contract.
If you want a different source, the source subpackage provides JSF (Jenkins Small Fast), SFC (Simple Fast Counter), Crypto (which uses crypto/rand) and Dumb (a simple incrementing number). You construct a faker with gofakeit.NewFaker(src, lock), passing the source and whether it should be thread safe. That second argument is the trade-off knob: turning locking off removes mutex overhead but makes the faker unsafe to share across goroutines.
There is also a global override. gofakeit.GlobalFaker = gofakeit.New(0) replaces the package-level faker, so the simple function calls route through your chosen source. This is the mechanism to reach for if you want crypto/rand behavior without rewriting every call site to use a faker variable.
The data flow is otherwise flat. A call like gofakeit.JobTitle() looks up a static data set, picks an index using the configured source, and returns a string. There is no schema, no state machine and no external service. The data/ directory in the repository holds the word lists and record sets that back these functions, which is why the package can claim zero dependencies: the data ships with the code.
Installing gofakeit and generating your first struct
Installation is a single go get against the v7 module path. The go.mod file confirms the module is github.com/brianvoe/gofakeit/v7 and targets go 1.22, so your toolchain needs to be at least that version.
go get github.com/brianvoe/gofakeit/v7After that, the simplest use is a package-level call. No initialization is required; the README says that if you use the default global usage and do not care about seeding, there is nothing to set.
import "github.com/brianvoe/gofakeit/v7"
gofakeit.Name()
gofakeit.Email()
gofakeit.Phone()For reproducible output, seed it. Passing 0 tells gofakeit to use crypto/rand for the seed, which means the run will not repeat; passing a fixed number makes it repeat.
import "github.com/brianvoe/gofakeit/v7"
gofakeit.Seed(8675309)The more interesting path is Struct, which fills a struct by reflection. You pass a pointer, and fields get values based on their type. Tags refine the behavior: a fake tag names a function in lowercase, fakesize controls slice and map length, and skip or - opts a field out.
type Foo struct {
Name string `fake:"{firstname}"`
Number string `fake:"{number:1,10}"`
RandStr string `fake:"{randomstring:[hello,world]}"`
Regex string `fake:"{regex:[abcdef]{5}}"`
Map map[string]int `fakesize:"2"`
Skip *string `fake:"skip"`
}
var f Foo
err := gofakeit.Struct(&f)The README's own example output shows Name as fred, Number as 4, RandStr as world, Regex as cbdfc, a two-entry map, and Skip left as nil. Supported field types include the sized integer and float families, bool, string, arrays, pointers, maps, nested and embedded structs, and time.Time, which can also take a format tag. If Struct returns an error, check that you passed a pointer and that every tag names a function that actually exists.
Where gofakeit stops being the right choice
The library generates values; it does not validate them. A generated credit card number is not guaranteed to pass a Luhn check, a generated SSN is not guaranteed to be in a valid range, and a generated address is not guaranteed to be deliverable. If your test asserts that downstream validation accepts the output, you are testing the generator's data set, not your validator. The README does not claim otherwise, and there is no validation layer in the top-level file list.
Reproducibility has a sharp edge. Seed(0) is documented as using crypto/rand to generate a number, so a test that calls Seed(0) and then compares against a golden file will fail on the next run. You need a fixed non-zero seed for that pattern, and you need to keep it stable across refactors.
Concurrency has a cost. The default source is thread locked, which is the safe choice but adds mutex contention under heavy parallel test load. NewFaker with lock set to false removes that cost and removes the safety.
Finally, gofakeit is a Go library. If your test suite is in Python, JavaScript or Java, none of this transfers. The repository is Go only, and the cmd/ tools are Go binaries. Teams running polyglot test suites will end up maintaining two fake-data strategies.
How gofakeit compares to Faker-style generators in other ecosystems
The obvious comparison is the Faker family: Faker for Python, faker.js for JavaScript, and the original Ruby Faker that popularized the locale-based provider model. The difference in approach is structural. Faker implementations typically organize data by locale, so a single instance can produce French names or Japanese addresses depending on configuration, and the provider list is extensible at runtime. gofakeit's data lives in a data/ directory and is addressed through function names; the README does not present a locale switching mechanism, so the output is effectively one data set.
That is a real limitation if you are testing internationalization. It is also why gofakeit stays simple: no locale registry, no provider loading, no configuration file. You import the package and call functions.
The second comparison is Go's own testing/quick, which generates random values for arbitrary types via reflection. testing/quick is built for property-based testing and shrinks failing cases; gofakeit is built for realistic-looking data. A random string from testing/quick looks like garbage, which is fine for a property test and useless for a demo screenshot. Conversely, gofakeit does not shrink, so it is a poor fit for property-based testing workflows. If you need both, they are not in conflict: use testing/quick for invariants and gofakeit for fixtures.
Maintenance, versioning and licence
The repository is not archived, and the last push was on 2026-09-19. Releases are tagged on a v7 line, with v7.9.0 (ID Generator) in November 2025, v7.3.0 (ISBN) in June 2025, and v7.0.0 in February 2024, which the release title attributes to the move to math/rand/v2. That v7.0.0 change is the upgrade cost to plan for: the module path carries the major version, so moving from v6 means updating import paths across your codebase, not just bumping a version in go.mod.
Within v7, new releases have added functions rather than changing existing call signatures, based on the release titles. That suggests additive upgrades, but the README does not document a deprecation policy, and it does not document rollback. Treat a version bump as something to verify against your own test suite rather than something to assume is safe.
The licence is MIT, per the LICENSE.txt file and the badge in the README. That is permissive and generally compatible with closed-source use, but the licence text is the authority and this article is not legal advice. The practical implication for a library with zero dependencies is that there is no transitive licence surface to audit: what you review is one MIT file.
Editorial conclusion
Adopt gofakeit if you are writing Go tests or fixtures and want fake values without pulling in a dependency tree; the MIT licence and zero-dependency design keep it easy to vendor. Skip it if you need a standalone fake-data server, a database seeder, or a non-Go language. Before adopting, verify that the function you plan to call exists in v7 by checking the GoDoc link in the README, and confirm whether you need reproducible output, because gofakeit.Seed(0) uses crypto/rand and will not reproduce a previous run.
Frequently asked questions
What is faking data called?
The practice is usually called fake data generation or test data generation. gofakeit describes itself as a random data generator written in Go, and its README lists 310+ functions for producing names, addresses, emails, credit card numbers and other values.
How do I install gofakeit in a Go project?
Run go get github.com/brianvoe/gofakeit/v7. The go.mod in the repository declares the module as github.com/brianvoe/gofakeit/v7 and targets go 1.22, so your toolchain needs to be at least that version.
How do I make gofakeit produce reproducible output?
Call gofakeit.Seed with a fixed non-zero number, for example gofakeit.Seed(8675309). The README states that passing 0 makes gofakeit use crypto/rand to generate a number, which will not reproduce a previous run.
Can gofakeit fill a struct automatically?
Yes. Pass a pointer to your struct to gofakeit.Struct, and it generates values for supported field types including sized integers and floats, bool, string, arrays, pointers, maps, nested and embedded structs, and time.Time. Fields can carry fake, fakesize and format tags to control the generated data.
Does gofakeit have dependencies?
The README lists zero dependencies as a feature, and the go.mod file contains only the module declaration and the Go version directive. The word lists and record sets that back the functions ship in the repository's data directory.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/brianvoe-gofakeit)