brianvoe / gofakeit Goto Github PK
View Code? Open in Web Editor NEWRandom fake data generator written in go
License: MIT License
Random fake data generator written in go
License: MIT License
It's worth mentioning in the docs that the library users must init random with some seed, otherwise the fake data won't be really random.
To put it simply, one should add some init code, e.g.:
rand.Seed(time.Now().UnixNano())
Add all variations of uuid versions
Hi.
I'm using your gofakeit in my cli open source, the flog
Today, I've tried the installing the flog in centos:latest docker, but go get
failed with undefined: math.Round
error message. Yes, the Round
method is available since Go 1.10. I didn't know it.
So, I think it is good idea that notes the required Go version on README to let users know the required Go version to use gofakeit.
How about you?
Ideally the package should be renamed to gofakeyourself
Miss you dad
I refactored this function a while ago and I had a feeling something is wrong. The old code was in replaceWithNumbers and I moved it to randDigit, and now all its callers are affected.
The issue is that rand.Intn(9)
returns in the interval [0, 9)
When the patch is applied 19 Examples will fail
Got : 6536459948995369
want:6587271570245748
Hello, nice job on the package, it looks neat and has a good documentation.
I have 2 main issues:
The refactoring will be big and I don't see a way to make it backward compatible, to make all the functions as methods and using a custom private random generator.
Any ideas?
Error: cannot find package "github.com/brianvoe/gofakeit/v5"
Go get github.com/brianvoe/gofakeit is pulling the code. But throwing error :
goserver1 % go get github.com/brianvoe/gofakeit
compile: version "go1.14" does not match go tool version "go1.14.2"
compile: version "go1.14" does not match go tool version "go1.14.2"
compile: version "go1.14" does not match go tool version "go1.14.2"
compile: version "go1.14" does not match go tool version "go1.14.2"
compile: version "go1.14" does not match go tool version "go1.14.2"
compile: version "go1.14" does not match go tool version "go1.14.2"
compile: version "go1.14" does not match go tool version "go1.14.2"
compile: version "go1.14" does not match go tool version "go1.14.2"
compile: version "go1.14" does not match go tool version "go1.14.2"
compile: version "go1.14" does not match go tool version "go1.14.2"
compile: version "go1.14" does not match go tool version "go1.14.2"
compile: version "go1.14" does not match go tool version "go1.14.2"
It doesn't happen every time but sometimes domains will have a space character in them such as this one: "internalweb services.net"
Its invalid so it breaks test code.
Too general. Change to httpstatuscode
It will be fine to have ability to register custom functions which can be used in in structure tags:
func MyStrangeName() string {
return "strange name"
}
type MyStruct struct {
name string `fake:"my_strange_name"`
}
func main() {
gofakeit.RegisterString("my_strange_name", MyStrangeName)
// apply
var s MyStruct
gofakeit.Struct(&s)
}
The one that is in there always goes down. Try a more reliable one https://picsum.photos/
Hi, great work on gofakeit! If you have time, there are a couple of methods that I used heavily in the Ruby Faker Gem, which ould be awesome to see make it over here:
If these, or any other from stympy/faker made it into gofakeit, I would be very grateful!
It would be awesome to have a function to create a defined length string containing only numbers. Something like:
gofakeit.NumericString(5) // returns "83756"
Sometimes we get invalid domains names from DomainName( ) such as "corporate24/7.biz".
Can I use gofakeit to generate a skew dataset with specified skewness?
I'd like to generate data, but also ensure that the data differs from one call to another within a specific scope. As an example:
d1 := data{name: gofakeit.Name() }
d2 := data{name: gofakeit.Name() }
I want to guarantee that d1.name
and d2.name
are not the same. But I don't really care what the values are.
Just lettin' ya know Brian. โ๏ธ
I noticed that HackerIngverb
is missing in the FuncLookups.
The file hacker.go
defines 6 functions for generating fake data, but only 5 are added during addHackerLookup
.
I can provide a pull request. I just wanted to check if this is missing intentionally.
This library has an impressive collection of methods.
Unfortunately, having all methods defined at top level without being able to instantiate a generator value forbids the use of reflect to inspect this package (ie templates, generators).
Think of a template filter with name "fakeit" and arguments method, args...
Or a tag on a struct field like fakeit:"email".
The only way to implement something like this right now is to write a huge switch statement and painstakingly map all function names manually.
Any plans of providing such an API?
Have this package something similar?
Like, I want to generate a number from 0 to 100 with step 5, like 0, 5, 10, 15, 20...
Generate random questions
Hey great job on this package. You are the best and super sexy might i just add.
That being said add timezones you crazy son of a bitch!
From https://play.golang.org/p/7n0az_D-uZ9
package main
import (
"fmt"
"math"
"github.com/brianvoe/gofakeit"
)
func main() {
fmt.Printf("%d", gofakeit.Number(math.MinInt32, math.MaxInt32))
}
results in
panic: invalid argument to Intn
goroutine 1 [running]:
math/rand.(*Rand).Intn(0x43e260, 0x0, 0x0, 0xbab699fc)
/usr/local/go/src/math/rand/rand.go:169 +0xc0
math/rand.Intn(...)
/usr/local/go/src/math/rand/rand.go:329
github.com/brianvoe/gofakeit.randIntRange(...)
/tmp/gopath082295618/pkg/mod/github.com/brianvoe/[email protected]+incompatible/misc.go:104
github.com/brianvoe/gofakeit.Number(0x80000000, 0x7fffffff, 0x7d9, 0x28b2)
/tmp/gopath082295618/pkg/mod/github.com/brianvoe/[email protected]+incompatible/number.go:10 +0x60
main.main()
/tmp/sandbox693462447/prog.go:11 +0x40
Program exited: status 2.
Can only get about halfway there (+/- 1) based on how randIntRange()
works.
Pet Names would be a good new category
A bunch of emojis are broken or are really useless
There is just on example with tag usage for structures in README ("skip" only). It will be fine to add more examples.
Fruits, vegetables, meats, breads, sweats, etc...
Be able to make something like this work {{randomstring:firstname,lastname}} that would randomly give you either {firstname} or {lastname} then when it loops again would generate either a random firstname or lastname
I'd like be able to create a "fakeit" client object that could be instantiated
Example usage:
// parameter is the seed
f := gofakeit.New(0)
f.Name()
It is safe/expected to call gofakeit.Seed(?)
many times? What happens?
Make sure credit cards are luhn valid and add test credit cards to data
https://www.paypalobjects.com/en_GB/vhelp/paypalmanager_help/credit_card_numbers.htm
Would be nice for devlog to have a way to randomly generate json data
I need to generate an age, and I noticed that struct.go is missing reflect types for all uint
types, and it will remain a 0 value.
You have the SSN formatted as ###-###-####, but it should be ###-##-####. Please disregard if this is not for the US.
It seems that the Struct
method does not fill out the structure fields at all, except for those that have a person.first
and person.last
. I expected that with this method I could fill the structure using the names of the functions available in the package.
package model_test
import (
"testing"
"time"
"github.com/brianvoe/gofakeit/v4"
"github.com/stretchr/testify/assert"
)
type User struct {
Name string `fake:"{name}"`
PersonName string `fake:"{person.name}"`
PersonFirstLastName string `fake:"{person.first} {person.last}"`
Email string `fake:"{email}"`
ContactEmail string `fake:"{contact.email}"`
PersonContactEmail string `fake:"{person.contact.email}"`
}
func TestFake(t *testing.T) {
u := new(User)
gofakeit.Seed(time.Now().UnixNano())
gofakeit.Struct(u)
assert.NotEmpty(t, u.Name) // fail
assert.NotEmpty(t, u.PersonName) // fail
assert.NotEmpty(t, u.PersonFirstLastName) // success
assert.NotEmpty(t, u.Email) // fail
assert.NotEmpty(t, u.ContactEmail) // fail
assert.NotEmpty(t, u.PersonContactEmail) // fail
}
I think it will be useful to have a generator providing language codes like "en", "ru" etc.
looks similar to Price
but it is up to you sure :)
Hello, I tried gofakeit to generate random URLs,
but one of the test failed due to a invalid domain in the URL:
Error: Received unexpected error:
parse http://www.forwardweb services.info/synthesize: invalid character " " in host name
is generating invalid urls an expected behaviour?
It will be very helpful to know what each release is changing.
Also it seems like there was a breaking change with the format of SSN in a recent release.
To reproduce:
gofakeit.Number(math.MinInt64, 0)
gofakeit.Number(math.MinInt64+1, 0)
However, this runs just fine:
gofakeit.Number(math.MinInt64+2, 0)
Using the below command for installation
go get github.com/brianvoe/gofakeit/v5
gives following error
package github.com/brianvoe/gofakeit/v5: cannot find package "github.com/brianvoe/gofakeit/v5" in any of:
/usr/local/Cellar/go/1.14.2_1/libexec/src/github.com/brianvoe/gofakeit/v5 (from $GOROOT)
/Users/user/go/src/github.com/brianvoe/gofakeit/v5 (from $GOPATH)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.