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

Add rand int #211

Merged
merged 9 commits into from
Dec 2, 2020
Merged

Add rand int #211

merged 9 commits into from
Dec 2, 2020

Conversation

kochurovro
Copy link
Contributor

No description provided.

@kochurovro kochurovro mentioned this pull request Nov 6, 2019
@mholt
Copy link
Contributor

mholt commented Nov 6, 2019

Nice! Does rand get seeded anywhere? I don't see any call to rand.Seed: https://github.com/Masterminds/sprig/search?q=seed&unscoped_q=seed

@kochurovro
Copy link
Contributor Author

kochurovro commented Nov 6, 2019

Oh. Yep. I forgot about it. Going to update it

functions.go Outdated
@@ -199,7 +199,10 @@ var genericMap = map[string]interface{}{
}
return val
},
"randInt": func(min, max int) int { return rand.Intn(max-min) + min },
"randInt": func(min, max int) int {
rand.Seed(time.Now().UnixNano())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be done only once, preferably:

func init() {
    rand.Seed(time.Now().UnixNano())
}

@kochurovro
Copy link
Contributor Author

@mholt what u think about my solution for TestShuffle? Is it correct for test?

@mholt
Copy link
Contributor

mholt commented Nov 18, 2019

I don't really know why it had to change, but at a cursory glance it looks fine, as the tests appear to be passing, so, that's a good sign.

@Thiht
Copy link
Contributor

Thiht commented Aug 15, 2020

Hi, any news on this PR? :)

docs/math.md Outdated Show resolved Hide resolved
mattfarina and others added 3 commits December 2, 2020 09:38
Co-authored-by: Daniel <daniel.hoherd@gmail.com>
Signed-off-by: Matt Farina <matt@mattfarina.com>
@mattfarina mattfarina merged commit ce41f42 into Masterminds:master Dec 2, 2020
@kochurovro kochurovro deleted the add--randInt branch December 2, 2020 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants