Documentation
¶
Index ¶
Constants ¶
const ( TOTAL_BITS = 128 TOTAL_BYTES = TOTAL_BITS / int(unsafe.Sizeof(uint8(0))*8) STRING_LENGTH = TOTAL_BYTES*2 + 4 VERSION_BYTE_INDEX = 6 VARIANT_BYTE_INDEX = 8 )
const ( // VERSION_BYTE_MASK is the mask for the version byte. VERSION_BYTE_MASK uint8 = 0b11110000 // V1 is the version that is made from the timestamp and MACAddress Version1 Version = 0b0001_0000 // V2 Not Implemented Version2 Version = 0b0010_0000 // V3 is the version that hashes (MD5) given data into an UUID Version3 Version = 0b0011_0000 // V4 is the version that generates a random UUID Version4 Version = 0b0100_0000 // V5 is the version that hashes (SHA1) given data into an UUID Version5 Version = 0b0101_0000 )
Variables ¶
var ( // ErrInvalidVariant is returned when the variant is invalid. ErrInvalidVariant = errors.New("invalid UUID variant") )
var ( // ErrInvalidVersion is returned when the version is invalid. ErrInvalidVersion = errors.New("invalid UUID version") )
var ( // ErrMacAddrNotFound is returned when the mac address is not found ErrMacAddrNotFound = errors.New("mac address not found") )
var Nil = Empty()
Nil is the nil UUID (00000000-0000-0000-0000-000000000000).
var V1 v1
var V3 v3
V3 is a UUID version 3 generator, using MD5 hashing
var V4 v4
V4 is a UUID version 4 generator
var V5 v5
V5 is a UUID version 4 generator, using SHA-1 hashing
Functions ¶
func IsValidStringUUID ¶
IsValidStringUUID returns true if the string is a valid UUID.
func ValidateStringUUID ¶
ValidateStringUUID returns an error if the string is not a valid UUID.
Types ¶
type UUID ¶
type UUID [16]byte
UUID is a 128 bit (16 byte) Universal Unique IDentifier as defined in RFC-4122.
func StampVersionVariant ¶
StampVersion stamps the version and variant of the UUID.
func (UUID) IsEmpty ¶
IsEmpty returns true if the UUID is empty (00000000-0000-0000-0000-000000000000).
func (UUID) String ¶
String returns a string representation of the UUID in the following format: 00000000-0000-0000-0000-000000000000
type Variant ¶
type Variant uint
Variant represents the variant of the UUID.
func VariantFromValue ¶
VariantFromValue returns the variant of the UUID from the value, returns ErrInvalidVariant if the value is invalid.