Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
ErrUUIDInvalidEncode = errors.New("uuid: invalided encoded UUID")
)
The only error returned by this package, indicating an attempt to call uuid.Decode() with a string that doesn't appear to be fully formed UUID (or cannot be massaged into one).
Functions ¶
Types ¶
type UUID ¶
type UUID interface { // Exposed interface to a uuid, a 128-bit opaque unique identifier value // stored internally as two unsigned 64-bit integers. fmt.Stringer // UUIDs support the fmt.Stringer interface, as follows: // // String() Returns a string conversion of the uuid which can be decoded // with uuid.Decode(). The string represenation takes the format: // // HHHHHHHH-HHHH-HHHH-HHHH-HHHHHHHHHHHH // // Where H represents a lower-case hexidecimal character. // // For zero-value uuids, String() always return "" Bytes() []byte // Return a slice of bytes representing the uuid. If the uuid is // zero this will return nil. Array() [16]byte // Return an [16]byte array representing the uuid. If the uuid is // zero this will return a 16 byte array filled with zeros. Uint64() []uint64 // Return the uuid as a slice of uint64s. If the uuid is zero this // nil. IsZero() bool // Return true if the uuid is empty and contains no value. Equals(UUID) bool // Returns true if two uuids are an exact byte // match (internally). Len() int }
func Decode ¶
Decode a uuid from a string representation. The representation must contains at least 32 hexidecimal characters plus optional (and ignored) hyphens.
func FromArray ¶
Returns a UUID from a 16 byte binary represenation of the uuid (available via .Array() or .Bytes())
func New ¶
func New() UUID
Returns a new uuid. The first uuid generated is created using a psuedo-random generator and a seed based on package initialization time. Subsequent uuids are generated as offsets of this initial uuid using a psuedo-random offset also computed at initialization time. For more random uuids, use NewRandom(). New() uses a small queue, is more optimized than NewRandom() and parallelizes the generator
func NewRandom ¶
func NewRandom() UUID
Returns a new psuedo-randomly generated uuid based on a seed computed from the system time at package initialization. Psuedo-random uuid generation is more cpu intensivev and is not optimized for extreme use cases. Normally, one need only use New() to create new uuids.