google / uuid

Go package for UUIDs based on RFC 4122 and DCE 1.1: Authentication and Security Services.
BSD 3-Clause "New" or "Revised" License
5.26k stars 362 forks source link

Allow concurrent, re-creatable usage #44

Closed trabetti closed 5 years ago

trabetti commented 5 years ago

Related to issue #43. To enable concurrent and re-creatable usage, I have added a UuidSource, similar to the source in math/rand. It holds its own random number generator (the rander). I have added only the methods that seemed relevant: SetRand(), NewRandom() (version 4) and New(). From what I saw, other methods do not use random number generator (except the clock sequence but this can't be recreated anyway).

trabetti commented 5 years ago

Build failed. I used math/rand.Rand as an io.Reader and it failed saying it does not implement the io.Reader interface. It does not fail in my env, I think it is because of the Go version in the travis build is old. Although I see that math/rand.Rand implements io.Reader since 2015. Anyway, it is just for the tests, I will use a string reader instead.

trabetti commented 5 years ago

@pborman

trabetti commented 5 years ago

@pborman , do you still intend to merge this? Thank you!

pborman commented 5 years ago

Sorry for the delay. Thank you for the contribution.