Documentation
¶
Overview ¶
Package uuid is a port of https://github.com/gofrs/uuid with functions only for parsing UUID from string.
Index ¶
Constants ¶
View Source
const ( V1 byte // Version 1 (date-time and MAC address) V3 // Version 3 (namespace name-based) V4 // Version 4 (random) V5 // Version 5 (namespace name-based) V6 // Version 6 (k-sortable timestamp and random data, field-compatible with v1) [peabody draft] V7 // Version 7 (k-sortable timestamp and random data) [peabody draft] )
UUID versions.
View Source
const ( VariantNCS byte = iota VariantRFC4122 VariantMicrosoft VariantFuture )
UUID layout variants.
View Source
const Size = 16
Size of a UUID in bytes.
Variables ¶
View Source
var ( ErrTooShort = errors.New("too short") ErrTooLong = errors.New("too long") ErrInvalidHyphenPlacement = errors.New("invalid hyphen placement") ErrInvalid = errors.New("invalid") )
View Source
var Nil = UUID{}
Nil is the nil UUID, as specified in RFC-4122, that has all 128 bits set to zero.
Functions ¶
This section is empty.
Types ¶
type UUID ¶
UUID is an array type to represent the value of a UUID, as defined in RFC-4122.
func CanonicalFromString ¶
func FromString ¶
FromString returns a UUID parsed from the input string. Input is expected in a form accepted by UnmarshalText.
func (*UUID) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface. Following formats are supported:
"6ba7b810-9dad-11d1-80b4-00c04fd430c8",
"{6ba7b810-9dad-11d1-80b4-00c04fd430c8}",
"urn:uuid:6ba7b810-9dad-11d1-80b4-00c04fd430c8"
"6ba7b8109dad11d180b400c04fd430c8"
"{6ba7b8109dad11d180b400c04fd430c8}",
"urn:uuid:6ba7b8109dad11d180b400c04fd430c8"
ABNF for supported UUID text representation follows:
URN := 'urn'
UUID-NID := 'uuid'
hexdig := '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' |
'a' | 'b' | 'c' | 'd' | 'e' | 'f' |
'A' | 'B' | 'C' | 'D' | 'E' | 'F'
hexoct := hexdig hexdig
2hexoct := hexoct hexoct
4hexoct := 2hexoct 2hexoct
6hexoct := 4hexoct 2hexoct
12hexoct := 6hexoct 6hexoct
hashlike := 12hexoct
canonical := 4hexoct '-' 2hexoct '-' 2hexoct '-' 6hexoct
plain := canonical | hashlike
uuid := canonical | hashlike | braced | urn
braced := '{' plain '}' | '{' hashlike '}'
urn := URN ':' UUID-NID ':' plain
func (UUID) ValidVersion ¶
Click to show internal directories.
Click to hide internal directories.