8000 rander should be injected with SetRand(r io.Reader) to be reproducible with seeds · Issue #105 · rs/xid · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
rander should be injected with SetRand(r io.Reader) to be reproducible with seeds #105
Open
@ugol

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

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

      0