Skip to content

Propsal: enable seeding the random source #642

@Veermove

Description

@Veermove

Hello,
Would it be possible to add a way to seed the random source used in RandomString? Currently the RandomString calls rand.Int64 which calls stdlib rand.Int64. I know there is a way to use stdlib rand.Seed but since it was depracated you have to jump through hoops to enable that behavior.

It would be great if you could do

lo.Seed(42)
lo.RandomString(...)

which would generate the same string every time. Of course the default behavior should stay as is, that way i don't think this would be a breaking change.
The motivation being predictable testcases.

In anyway, thanks for this great library

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