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

question: Feature request to add rand.Source or Seed to the pkg/v1/random functions #1674

Closed
ktarplee opened this issue Apr 25, 2023 · 0 comments · Fixed by #1675
Closed
Labels
question Further information is requested

Comments

@ktarplee
Copy link
Contributor

ktarplee commented Apr 25, 2023

As a user of the library, I would like to be able to generate random test images but do so in a deterministic way. I would like to have options from the random.Index(), random.Image(), and random.Layer() functions that allow me to set the rand.Source or the seed to use.

During unit testing I find the random images useful however they are always different (even when I am re-running a test) so it is a larger cognitive load to track what is happening in my test. I cannot add a conditional break-point on the sha256 in one of these images. I do not care what the digest is or what the contents of the images are, I just want them to stay constant unless I change the seed.

The only place a random number generator is used is in Layer() and actually two different random number generators are called. crypto/rand (for the io.Reader interface) and math/rand (for an integer).

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

Successfully merging a pull request may close this issue.

1 participant