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

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

Open
bfallik opened this issue Apr 4, 2017 · 5 comments
Open

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

bfallik opened this issue Apr 4, 2017 · 5 comments

Comments

@bfallik
Copy link

bfallik commented Apr 4, 2017

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
Copy link
Author

bfallik commented Apr 4, 2017

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
Copy link
Owner

+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
Copy link
Author

bfallik commented Apr 7, 2017

Cool. PR at #5.

@dustinkirkland
Copy link
Owner

dustinkirkland commented Apr 10, 2017 via email

@davidbanham
Copy link

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.

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

No branches or pull requests

3 participants