Skip to content

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

@ktarplee

Description

@ktarplee

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions