Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Number() can't generate across range of ints #52

Closed
carldunham opened this issue Jun 21, 2019 · 1 comment
Closed

Number() can't generate across range of ints #52

carldunham opened this issue Jun 21, 2019 · 1 comment

Comments

@carldunham
Copy link
Contributor

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/gofakeit@v3.18.0+incompatible/misc.go:104
github.com/brianvoe/gofakeit.Number(0x80000000, 0x7fffffff, 0x7d9, 0x28b2)
	/tmp/gopath082295618/pkg/mod/github.com/brianvoe/gofakeit@v3.18.0+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.

@brianvoe
Copy link
Owner

Sorry you came across that but I am using it to the best of my knowledge. This might be a little out of my wheel house. If you figure it out im more than willing to make adjustments to making it work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants