Skip to content

Add rand int - #211

Merged
mattfarina merged 9 commits into
Masterminds:masterfrom
kochurovro:add--randInt
Dec 2, 2020
Merged

mattfarina merged 9 commits into
Masterminds:masterfrom
kochurovro:add--randInt

Conversation

@kochurovro

Copy link
Copy Markdown
Contributor

No description provided.

@kochurovro kochurovro mentioned this pull request Nov 6, 2019
@mholt

mholt commented Nov 6, 2019

Copy link
Copy Markdown
Contributor

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

kochurovro commented Nov 6, 2019 •

Copy link
Copy Markdown
Contributor Author

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

Comment thread functions.go Outdated
},
"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
Copy Markdown
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
Copy Markdown
Contributor Author

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

@mholt

mholt commented Nov 18, 2019

Copy link
Copy Markdown
Contributor

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

Thiht commented Aug 15, 2020

Copy link
Copy Markdown
Contributor

Hi, any news on this PR? :)

Comment thread docs/math.md Resolved
@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