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

Implement NullUUID #54

Closed pmalekn closed 2 months ago

pmalekn commented 4 years ago

In order to allow uuid.UUID to work with the standard sql package to represent a UUID value that can be NULL in the database I suggest to implement a NullUUID the same way as it's done in http://github.com/satori/go.uuid [1]

[1] https://pkg.go.dev/github.com/satori/go.uuid@v1.2.0?tab=doc#NullUUID

pborman commented 4 years ago

Looking at the code it appears that NullUUID can actually be implemented outside of the uuid package itself. Have you considered making a simple package that provides this type?

pmalekn commented 4 years ago

Ha! Didn't think about this obvious solution. Still it would be nice to implement it in here to make it more idiomatic. Instead of importing a separate package and calling a type e.g. null.UUID we could use the very same package that defines the uuid.UUID and use the type as uuid.Null.

I'd be happy to submit a PR basing the work on satori's implementation.

agravelot commented 2 years ago

This issue seems to be fixed, am I wrong?

Alcas1 commented 2 years ago

Should be able to close this one

jensilo commented 2 months ago

Just as I've stumbled across this personally as well, FYI there is a generic sql.Null[T].

pmalekn commented 2 months ago

Looks like #76 solved this and this change got released in 1.3.0: https://github.com/google/uuid/releases/tag/v1.3.0 🎉