GithubHelp home page GithubHelp logo

gofakeit's Introduction

Hi, Thanks for checking me out!

Iโ€™m currently working on Gofakeit and other services associated to it.

Support

Buy Me A Coffee

logo

gofakeit's People

Contributors

adambabik avatar alex-wzm avatar andrewcretin avatar bgadrian avatar borosr avatar brianvoe avatar bvoelker avatar cagriekin avatar calvernaz avatar daisy1754 avatar dminkovski avatar hbagdi avatar hound672 avatar kishaningithub avatar mgilbir avatar mingrammer avatar moul avatar mrpye avatar n3xem avatar petergeorgas avatar rcoy-v avatar se-omar avatar smt923 avatar sp628193 avatar stefanb avatar viridianforge avatar woodb avatar wulfharth7 avatar xiegeo avatar zacscoding avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gofakeit's Issues

Random generate is not seeded.

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())

Note for required go version on readme

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?

rename package

Ideally the package should be renamed to gofakeyourself

Miss you dad

Bug: Digit(), randDigit(), replaceWithNumbers does not return 9

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

Concurrency

Hello, nice job on the package, it looks neat and has a good documentation.

I have 2 main issues:

  1. is not concurrent safe, it uses rand.* global version
  2. I need one instance for each thread, and all the functions are public.

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?

go get github.com/brianvoe/gofakeit/v5 giving error

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

internal/race

compile: version "go1.14" does not match go tool version "go1.14.2"

unicode/utf8

compile: version "go1.14" does not match go tool version "go1.14.2"

runtime/internal/sys

compile: version "go1.14" does not match go tool version "go1.14.2"

math/bits

compile: version "go1.14" does not match go tool version "go1.14.2"

unicode

compile: version "go1.14" does not match go tool version "go1.14.2"

encoding

compile: version "go1.14" does not match go tool version "go1.14.2"

unicode/utf16

compile: version "go1.14" does not match go tool version "go1.14.2"

image/color

compile: version "go1.14" does not match go tool version "go1.14.2"

github.com/brianvoe/gofakeit/data

compile: version "go1.14" does not match go tool version "go1.14.2"

sync/atomic

compile: version "go1.14" does not match go tool version "go1.14.2"

internal/cpu

compile: version "go1.14" does not match go tool version "go1.14.2"

runtime/internal/atomic

compile: version "go1.14" does not match go tool version "go1.14.2"

Custom faker functions

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)   
}

Extra Method Suggestions

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!

defined length numberstring

It would be awesome to have a function to create a defined length string containing only numbers. Something like:

gofakeit.NumericString(5) // returns "83756"

Feature: ๐Ÿ”€ Ensure different

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.

HackerIngverb missing in FuncLookups

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.

Unable to use it with reflect

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?

Random Number with step

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

Add timezones to gofakeit

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!

Number() can't generate across range of ints

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

Pet Names would be a good new category

Add example with tags usage

There is just on example with tag usage for structures in README ("skip" only). It will be fine to add more examples.

Add food

Fruits, vegetables, meats, breads, sweats, etc...

Generate from multi inner brackets

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

Fakeit client instead of global/package vars/seed

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?

Random json data

Would be nice for devlog to have a way to randomly generate json data

struct.go missing uint* types

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.

SSN Formatting

You have the SSN formatted as ###-###-####, but it should be ###-##-####. Please disregard if this is not for the US.

Struct method almost doesn't do anything

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.

Example

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
}

Space character in url domain

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?

Can you add a changelog?

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.

Installation Issue

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.