dustinkirkland / golang-petname

Apache License 2.0
213 stars 38 forks source link

move init() from the shared package into the CLI #4

Open bfallik opened 7 years ago

bfallik commented 7 years ago

Hi,

We'd like to use your library to generate nonces but I'm concerned about the init() function that's included in petname.go. This init() will be called on startup and could conflict with other calls to rand.Seed().

In our case we have some code to alternate between a specific seed in order to repeat a test run and time.Now().UTC().UnixNano() for psuedo-random behavior.

Would you be open to simple PR to move the init() into https://github.com/dustinkirkland/golang-petname/blob/master/cmd/petname/main.go? This shouldn't affect the behavior of the petname utility but it will make it easier for us to reuse the library.

Thanks, brian

bfallik commented 7 years ago

I should add that another approach is to modify this package to use it's own rand.Rand object instead of the global one.

dustinkirkland commented 7 years ago

+1, that's a fine approach. Just go ahead and move the seed to the main.go. That's definitely where it belongs. Thanks!

bfallik commented 7 years ago

Cool. PR at https://github.com/dustinkirkland/golang-petname/pull/5.

dustinkirkland commented 7 years ago

Great, thanks. I've merged it and pushed trunk. I'll release 2.7 very soon.

Cheers! Dustin

:-Dustin @dustinkirkland

On Fri, Apr 7, 2017 at 3:25 PM, Brian Fallik notifications@github.com wrote:

Cool. PR at #5 https://github.com/dustinkirkland/golang-petname/pull/5.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/dustinkirkland/golang-petname/issues/4#issuecomment-292642870, or mute the thread https://github.com/notifications/unsubscribe-auth/AAzMhkRqM7f_sxVG5cubLdu7WUIIrz7Wks5rtpu8gaJpZM4MzZ3E .

davidbanham commented 7 years ago

How is this versioned for users of the package?

This is a breaking change to API of the petname Go package. The "blessed" Go way is to never change the API, but the more pragmatic approach is to version with semver and tag releases in Github. That way tools like glide can pick up the versions.