Go: proposal: add uuid generator to stdlib

Created on 12 Feb 2018  Â·  12Comments  Â·  Source: golang/go

Currently we generate uuid/guid with external packages or original implementations using crypto/rand etc...
And in some cases you use other languages' library...
As I argued on golang-nuts, I propose to implement the generator as a standard package.
https://groups.google.com/forum/#!topic/golang-nuts/J_htXsnVjdY

RFC4122 defines the specification of UUID representation.
And at first, how's to support uuid v4 package to create random ids?

FrozenDueToAge Proposal

Most helpful comment

A UUID generator in the stdlib that only supports one version and one
string format is kind of awkward, IMO. Inevitably, somebody will want
Microsoft’s {UUID in braces} or urn:uuid:1234... and then they’re back to
square one. Generally, whenever I’ve worked with UUIDs we’ve kept them as
[16]byte until they need to be sent in text format.
Le lun. 26 févr. 2018 à 13:50, Russ Cox notifications@github.com a écrit :

Proposal: in crypto/rand, add

func UUID(rand io.Reader) (string, error)

only returns random UUIDs, not all the other ones.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/golang/go/issues/23789#issuecomment-368662850, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AFnwZy-SSLmShh0il6s-W2agXQYZG66mks5tYycmgaJpZM4SB99P
.

All 12 comments

The bar for inclusion in the standard library is very high:
https://golang.org/doc/faq#x_in_std

and it kind of works backwards: first you need working, stable code and then submit a proposal for inclusion. Criterias are also not very clear at the moment, unfortunately.

Do you have some specific existing library that you want to propose for inclusion? I see there are already a few out there.

I thought this had come up in the past, but I at least can't find it on the issue tracker. Maybe it was the mailing list. But I'm pretty sure it was rejected previously. I'll keep this open, though.

Have the x repos been considered for such a package, instead of the standard library?

@mvdan wasn't there an issue a while back about freezing new x/ repos?

@ericlagergren doesn't ring a bell, and I can't find such an issue now. Specific packages may be frozen, but I don't know about any general freeze rule on existing (or new) x repos.

@mvdan He may be referring to https://github.com/golang/go/issues/17244

@dominikh yep, thanks. That's what I was remembering.

Proposal: in crypto/rand, add

func UUID(rand io.Reader) (string, error)

only returns random UUIDs, not all the other ones.

(For those Googling for the UUID spec, the correct RFC number is 4122.)

A UUID generator in the stdlib that only supports one version and one
string format is kind of awkward, IMO. Inevitably, somebody will want
Microsoft’s {UUID in braces} or urn:uuid:1234... and then they’re back to
square one. Generally, whenever I’ve worked with UUIDs we’ve kept them as
[16]byte until they need to be sent in text format.
Le lun. 26 févr. 2018 à 13:50, Russ Cox notifications@github.com a écrit :

Proposal: in crypto/rand, add

func UUID(rand io.Reader) (string, error)

only returns random UUIDs, not all the other ones.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/golang/go/issues/23789#issuecomment-368662850, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AFnwZy-SSLmShh0il6s-W2agXQYZG66mks5tYycmgaJpZM4SB99P
.

I'm withdrawing my proposal for crypto/rand. I don't have enough evidence that this is sufficient.

I don't think we have enough information about what is needed in the standard library. I think for now the answer is to keep using third-party packages.

Was this page helpful?
0 / 5 - 0 ratings