Skip to content

Releases: brianvoe/gofakeit

ID Generator

08 Nov 03:42

Choose a tag to compare

New: ID() β€” Fast, Human-Readable Random Identifier

(GoFakeIt v7.9.0)

gofakeit.ID() is a new high-performance identifier generator designed for speed, readability, and practically zero collision probability.

Unlike UUID v4 or XID, this generator is intentionally random-first, not structure-based.
Perfect for mock APIs, test data, fixtures, seed data, and temporary identifiers.


Highlights

  • Human readable alphabet, no confusing characters
    β†’ 23456789abcdefghjkmnpqrstuvwxyz (no 1, l, i or 0, o to alleviate confusion)
  • Fast
  • Memory Allocation
  • Generates from your rand source
  • Shorter than UUID, faster than XID, and requires no coordination

Example

id := gofakeit.ID()
fmt.Println(id)
// β†’ "3t9qf4c92npxhw7bg6y0"

Performance Benchmarks

Measured on Go 1.25

Generator / Function Benchmark Name ops/sec ns/op B/op allocs/op
gofakeit.ID() BenchmarkID-10 31,383,146 37.8 ns 24 1
gofakeit.UUIDv4() BenchmarkUUIDv4-10 22,131,577 53.8 ns 48 1
github.com/rs/xid BenchmarkXID-10 16,190,817 74.2 ns 0 0
github.com/google/uuid (v4) BenchmarkGoogleUUIDv4-10 3,098,770 386.1 ns 64 2

Takeaway: gofakeit.ID() is ~2Γ— faster than XID and ~10Γ— faster than UUID v4, while being shorter and human-readable.


Collision Probability (Randomness Math)

  • ID length: 20 characters
  • Alphabet: 32 slots with one duplicated character (intentional) β†’ avoids retries, maximizes speed
  • Effective entropy: β‰ˆ 98.25 bits

Even under very large bursts, duplication is astronomically unlikely

Collision probability when generating n IDs within 1 second (birthday bound)

n (IDs in 1s) gofakeit.ID() collision probability
100,000 0.00000000000000000001326
1,000,000 0.000000000000000001326017
10,000,000 0.000000000000000132601736
100,000,000 0.000000000000013260173678
1,000,000,000 0.000000000001326017367838

For comparison (same n):

  • UUID v4 (122 bits): much lower probabilities (but significantly slower and longer)
  • XID: structural uniqueness (time + machine + pid + counter). Treat collisions as operationally zero when configured normally.

Need structural, sortable IDs? Use XID or Snowflake.
Want random, readable, fast? Use gofakeit.ID().


RNG Behavior

Mode Behavior
Default (gofakeit.ID()) PCG for speed, seeded via crypto/rand β†’ fast + unpredictable
Full crypto (NewFaker(source.NewCrypto())) crypto/rand for every ID β†’ maximum randomness (slower)
Deterministic (New(seed)) PCG with fixed seed β†’ reproducible ID sequences (useful for tests/fixtures)

We seed PCG with a cryptographic seed when seed == 0. This prevents accidental identical streams across processes/containers.


Example Usage

package main

import (
	"fmt"

	"github.com/brianvoe/gofakeit/v7"
	"github.com/brianvoe/gofakeit/v7/source"
)

func main() {
	// Fast ID β€” PCG, automatically crypto-seeded
	fmt.Println("fast ID:", gofakeit.ID())

	// Cryptographically secure per-ID RNG
	crypto := source.NewCrypto()
	faker := gofakeit.NewFaker(crypto, true)
	fmt.Println("crypto ID:", faker.ID())
}

ISBN

26 Jun 11:25

Choose a tag to compare

πŸ“š New Feature: ISBN Generation

This release adds support for generating valid ISBN identifiers, perfect for mock book data or publishing applications.

Generate a valid ISBN-10 or ISBN-13 string with customizable separator.

gofakeit.ISBN(ISBNOptions{Version: "13", Separator: "-"}) // "978-1-2345-6789-0"

🧰 Options

Field Description
Version "10" or "13" (default is "13")
Separator Custom string separator (e.g. "-", "")

Thanks to @phoenisx , gofakeit is even more versatile for testing systems that work with books, publishing tools, or educational content.

v7.0.0 - math/rand/v2

18 Feb 02:12

Choose a tag to compare

Gofakeit v7: What's New!

🎲 math/rand/v2 Integration

  • Better RNG πŸ”’: Now using math/rand/v2 for a more simplistic implementation and two new source types(pcg, chacha8).
  • Simplified faker 🧹: Refined faker struct for ease of use, mirroring the simplicity improvements of math/rand/v2.

✨ Highlights

  • New Sources : math/rand/v2 added PCG and ChaCha8. Gofakeit also added a sub package called source with additional sources in it.

Example New and NewFaker usage

import (
	"github.com/brianvoe/gofakeit/v7"
	"github.com/brianvoe/gofakeit/v7/source"
	"math/rand/v2"
)

// Uses math/rand/v2(PCG Pseudo) with mutex locking
faker := gofakeit.New(0)

// NewFaker takes in a source and whether or not it should be thread safe
faker := gofakeit.NewFaker(source rand.Source, threadSafe bool)

// PCG Pseudo
faker := gofakeit.NewFaker(rand.NewPCG(11, 11), true)

// ChaCha8
faker := gofakeit.NewFaker(rand.NewChaCha8([32]byte{0, 1, 2, 3, 4, 5}), true)


// Additional from Gofakeit sub package source

// JSF(Jenkins Small Fast)
faker := gofakeit.NewFaker(source.NewJSF(11), true)

// SFC(Simple Fast Counter)
faker := gofakeit.NewFaker(source.NewSFC(11), true)

// Crypto - Uses crypto/rand
faker := gofakeit.NewFaker(source.NewCrypto(), true)

// Dumb - simple incrementing number
faker := gofakeit.NewFaker(source.NewDumb(11), true)

πŸ™ Acknowledgments

A huge shoutout to our contributors and users! Your feedback and support have been invaluable. 🌟

Descriptions!!!

20 Jan 01:00

Choose a tag to compare

Thanks to the contributor @se-omar for all his great work in updating all the descriptions for lookups.

What's Changed

Full Changelog: v6.27.0...v6.28.0

Products!!! v6.26.0

05 Dec 23:06

Choose a tag to compare

πŸš€ Unleash the Power of Gofakeit 2.0: Elevate Your Data Faking Game! πŸš€

We're thrilled to introduce the latest and greatest update to Gofakeit, and this time, we've supercharged your data faking experience with a suite of powerful new functions! Say hello to the game-changing Product module, a feature-packed addition that will revolutionize the way you generate fake product information. πŸ›οΈβœ¨

🎁 Introducing the Product() Function:
Get ready to dive into a world of limitless possibilities with the Product() function! It's your go-to command for creating realistic and captivating fake product data effortlessly. Harness the magic within this function to craft dynamic, authentic product information that will leave your users amazed and engaged.

🏷️ ProductName() – Unleash the Creativity:
Forge compelling product identities with the ProductName() function. From quirky gadgets to sophisticated fashion pieces, this function lets you generate catchy and unique names that captivate your audience.

πŸ“ ProductDescription() – Tell a Story:
Bring your products to life with the ProductDescription() function! Craft vivid and intriguing descriptions that go beyond the mundane, ensuring your fake data is as immersive as it is imaginative. Spark curiosity and keep your users hooked.

πŸ”– ProductCategory() – Define the Essence:
Organize your products seamlessly with the ProductCategory() function. From electronics to fashion, create a diverse range of categories that add depth and structure to your fake data, making it more realistic and relatable.

🌟 ProductFeature() – Highlight the Best:
Elevate your product data with the ProductFeature() function! Showcase unique features that set your fake products apart. Whether it's cutting-edge technology or innovative design, this function lets you highlight the essence of your creations.

πŸ› οΈ ProductMaterial() – Craft Authenticity:
Immerse your users in the tactile world of your fake products with the ProductMaterial() function. Specify materials that resonate with authenticity, allowing your users to envision the quality and feel of the items you've meticulously crafted.

πŸŽ‰ Elevate your data generation game to new heights with Gofakeit 2.0! πŸŽ‰ Unleash creativity, captivate your audience, and make your fake data more convincing than ever before. The world is your oyster, and with Gofakeit's new Product module, you're the master creator of captivating, realistic product information! πŸš€πŸŒπŸ’Ό

Upgrade now and experience the thrill of data faking like never before! πŸš€βœ¨ #Gofakeit

Templates!!! v6.25.0

26 Nov 22:43

Choose a tag to compare

πŸš€ Exciting New Release for Gofakeit v6!

We're thrilled to introduce the latest version of Gofakeit, packed with a powerful addition to enhance your templating experience. Brace yourself for the introduction of custom outputs using Golang's template engine! 🌟

SPECIAL THANKS to @Mrpye for his work on this!

🎭 Template Magic
Now, you can unleash your creativity with custom outputs using Golang's template engine. We've integrated all available functions into the template engine, providing you with a versatile toolkit to craft dynamic and personalized content.

πŸ›  Additional Functions
But that's not all! We've gone the extra mile and added some game-changing functions to supercharge your template building:

ToUpper & ToLower: Easily manipulate text case for a polished appearance.
ToString: Swiftly convert any data type to a string.
ToDate: Effortlessly transform strings into time.Time objects.
SpliceAny, SpliceString, SpliceUInt, SpliceInt: Build slices dynamically, perfect for weighted scenarios and random selections.

🌐 Example Usages
To give you a taste of the excitement, here's a snippet showcasing the newfound template capabilities:

// Your template goes here
template := `
Subject: {{RandomString (SliceString "Greetings" "Hello" "Hi")}}

Dear {{LastName}},

{{RandomString (SliceString "Greetings!" "Hello there!" "Hi, how are you?")}}

{{Paragraph 1 5 10 "\n\n"}}

{{RandomString (SliceString "Warm regards" "Best wishes" "Sincerely")}}
{{$person:=Person}}
{{$person.FirstName}} {{$person.LastName}}
{{$person.Email}}
{{$person.Phone}}
`

// Applying the template
value, err := gofakeit.Template(template, nil)

New Functions!!!

07 Jun 16:21

Choose a tag to compare

Thanks to the help of @ViridianForge and @dminkovski! We now have Books, Movies, Middle Names, Blurbs and Company Slogans.

Added fakable interface

14 Apr 21:47

Choose a tag to compare

See https://github.com/brianvoe/gofakeit#fakeable-types

What's Changed

New Contributors

Full Changelog: v6.20.2...v6.21.0