Skip to content

Conversation

timmattison
Copy link

This function was in the version7.go file but it looks like it should only be available during testing. Leaving the function in the public API leaves open the possibility of people using it incorrectly and getting bad UUID v7 values.

@timmattison timmattison requested a review from a team as a code owner March 6, 2024 15:57
Copy link

google-cla bot commented Mar 6, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@bormanp
Copy link
Contributor

bormanp commented Mar 6, 2024

The "FromReader" functions were indeed added for testing purposes, but not for testing this package. This function makes it possible to have deterministic UUID's returned when validating a piece of software that uses this uuid package. I think NewV7 would be the most common way to get a V7 uuid. Using NewV7FromReader would only be used by software that needs this ability. That software would probably do something like:

import "crypto/rand"

var rander = rand.Read
...
    u := NewV7FromReader(rander)

and then in their validation tests they would change what rander points to.

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.

2 participants