-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuuid.go
34 lines (27 loc) · 782 Bytes
/
uuid.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package uuid
// Nil is the nil UUID (00000000-0000-0000-0000-000000000000).
var Nil = Empty()
// UUID is a 128 bit (16 byte) Universal Unique IDentifier as defined in RFC-4122.
type UUID [16]byte
// Empty returns an empty UUID (00000000-0000-0000-0000-000000000000).
func Empty() UUID {
return UUID{}
}
// IsEmpty returns true if the UUID is empty (00000000-0000-0000-0000-000000000000).
func (u UUID) IsEmpty() bool {
return u == Empty()
}
// Bytes returns the UUID as a copied byte slice.
func (u UUID) Bytes() [16]byte {
var b [16]byte
copy(b[:], u[:])
return b
}
// Version returns the version of the UUID.
func (u UUID) Version() Version {
return getVersion(u)
}
// Variant returns the variant of the UUID.
func (u UUID) Variant() Variant {
return getVariant(u)
}