predefined namespace UUIDs as pointers

This commit is contained in:
Maxim Bublis 2013-06-18 20:16:16 +04:00
parent fbbf090357
commit 3bbffb3eeb
1 changed files with 7 additions and 7 deletions

14
uuid.go
View File

@ -36,10 +36,10 @@ type UUID [16]byte
// Predefined namespace UUIDs.
var (
NamespaceDNS = UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
NamespaceURL = UUID{0x6b, 0xa7, 0xb8, 0x11, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
NamespaceOID = UUID{0x6b, 0xa7, 0xb8, 0x12, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
NamespaceX500 = UUID{0x6b, 0xa7, 0xb8, 0x14, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
NamespaceDNS = &UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
NamespaceURL = &UUID{0x6b, 0xa7, 0xb8, 0x11, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
NamespaceOID = &UUID{0x6b, 0xa7, 0xb8, 0x12, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
NamespaceX500 = &UUID{0x6b, 0xa7, 0xb8, 0x14, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
)
// Returns algorithm version used to generate UUID.
@ -110,7 +110,7 @@ func NewV1() (u *UUID, err error) {
}
// Returns UUID based on MD5 hash of namespace UUID and name.
func NewV3(ns UUID, name string) (u *UUID, err error) {
func NewV3(ns *UUID, name string) (u *UUID, err error) {
u, err = newFromHash(md5.New(), ns, name)
if err != nil {
return
@ -133,7 +133,7 @@ func NewV4() (u *UUID, err error) {
}
// Returns UUID based on SHA-1 hash of namespace UUID and name.
func NewV5(ns UUID, name string) (u *UUID, err error) {
func NewV5(ns *UUID, name string) (u *UUID, err error) {
u, err = newFromHash(sha1.New(), ns, name)
if err != nil {
return
@ -144,7 +144,7 @@ func NewV5(ns UUID, name string) (u *UUID, err error) {
}
// Returns UUID based on hashing of namespace UUID and name.
func newFromHash(h hash.Hash, ns UUID, name string) (u *UUID, err error) {
func newFromHash(h hash.Hash, ns *UUID, name string) (u *UUID, err error) {
u = new(UUID)
h.Write(ns[:])
h.Write([]byte(name))