Skip to content

v7.0.0 - math/rand/v2

Latest
Compare
Choose a tag to compare
@brianvoe brianvoe released this 18 Feb 02:12
· 35 commits to master since this release

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. 🌟