Skip to content

rander should be injected with SetRand(r io.Reader) to be reproducible with seeds #105

Description

@ugol

I added xid to JR [1], which is a CLI random data generator.
As in google uuid [2], to be possible to use different rand algorithms rander should be refactored like this:

var rander      = rand.Reader

and

func SetRand(r io.Reader) {
	if r == nil {
		rander = rand.Reader
		return
	}
	rander = r
}

that could also be useful to generate sequences with a seed (to be reproducible), though time should be mocked too (if that it's interesting I can submit another patch)

[1] https://github.com/jrnd-io/jr
[2] https://github.com/google/uuid

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions