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
π§Ή: Refinedfaker
struct for ease of use, mirroring the simplicity improvements ofmath/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. π