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

Feature request: Set custom seed for pseudo-random generator. #3

Open
smyrman opened this issue Dec 2, 2015 · 4 comments
Open

Feature request: Set custom seed for pseudo-random generator. #3

smyrman opened this issue Dec 2, 2015 · 4 comments

Comments

@smyrman
Copy link

smyrman commented Dec 2, 2015

I guess all that would be needed, would be to expose a method:

 // SetSource lets you customize the source used for generating random numbers.
 func SetSource(src rand.Source) {
   r = rand.New(src)
}
@smyrman
Copy link
Author

smyrman commented Dec 2, 2015

My particular use case for adding it would be to allow reproduce benchmarks or test results by setting the seed. Allowing to set the rand.Source opens up for more use cases than just allowing to set the seed, so better to expose SetSource than to expose a SetSeed function;-)

@smyrman smyrman mentioned this issue Dec 2, 2015
@smyrman
Copy link
Author

smyrman commented Dec 3, 2015

From the discussion on #1, I presume it probably make sense to wrap the provided src in a lockedSource insatance to make it thread safe.

@corpix
Copy link
Collaborator

corpix commented Mar 27, 2017

Thats make sense. I will be making a huge refactoring in a few weeks, there will be a constructor to create a custom faker instance with rand.Source from arguments.

@fgrosse
Copy link
Contributor

fgrosse commented Apr 8, 2017

fyi this issue seems related to the merged PR #15 which allows you to seed the RNG.

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

3 participants