Documentation ¶
Overview ¶
Package uuid is a universally unique identifier generator.
Index ¶
- Variables
- type UUID
- func GenerateV1(random bool) (UUID, error)
- func GenerateV2(id uint32, ldn uint8, random bool) (UUID, error)
- func GenerateV3(ns UUID, data []byte) (UUID, error)
- func GenerateV4(r io.Reader) (UUID, error)
- func GenerateV5(ns UUID, data []byte) (UUID, error)
- func Parse(s string) (UUID, error)
- func V1(random bool) UUID
- func V2(id uint32, ldn uint8, random bool) UUID
- func V3(ns UUID, data []byte) UUID
- func V4(r io.Reader) UUID
- func V5(ns UUID, data []byte) UUID
- func (guid UUID) GUID() string
- func (guid UUID) IsZero() bool
- func (guid UUID) MarshalBinary() ([]byte, error)
- func (guid UUID) MarshalJSON() ([]byte, error)
- func (guid UUID) MarshalText() ([]byte, error)
- func (guid *UUID) Scan(v interface{}) error
- func (guid UUID) String() string
- func (guid UUID) URN() string
- func (guid *UUID) UnmarshalBinary(b []byte) error
- func (guid *UUID) UnmarshalJSON(b []byte) error
- func (guid *UUID) UnmarshalText(b []byte) error
- func (guid UUID) Value() (driver.Value, error)
- func (guid UUID) Variant() Variant
- func (guid UUID) Version() Version
- type Variant
- type Version
Constants ¶
This section is empty.
Variables ¶
var (
// NamespaceDNS is the namespace UUID defined for DNS.
NamespaceDNS, _ = Parse("6ba7b810-9dad-11d1-80b4-00c04fd430c8")
// NamespaceURL is the namespace UUID defined for URL.
NamespaceURL, _ = Parse("6ba7b811-9dad-11d1-80b4-00c04fd430c8")
// NamespaceOID is the namespace UUID defined for ISO OID.
NamespaceOID, _ = Parse("6ba7b812-9dad-11d1-80b4-00c04fd430c8")
// NamespaceX500 is the namespace UUID defined for X.500 DN.
NamespaceX500, _ = Parse("6ba7b814-9dad-11d1-80b4-00c04fd430c8")
)
var ( // Null is a null UUID that translates to a 36-byte string with only zeroes. Null = UUID{} // ErrInvalid is the error for invalid UUID formats. ErrInvalid = errors.New("uuid: invalid uuid") )
Functions ¶
This section is empty.
Types ¶
type UUID ¶
type UUID [byteSize]byte
UUID is a 16-byte array Universally Unique IDentifier, as per the RFC 4122.
func GenerateV1 ¶ added in v0.3.0
GenerateV1 generates a version 1 UUID.
func GenerateV2 ¶ added in v0.3.0
GenerateV2 generates a version 2 UUID.
It basically returns a version 1 UUID but overrides the least significant 8 bits of the clock sequence by the variable "ldn", a local domain name, and the least significant 32 bits of the timestamp an integer identifier "id".
func GenerateV3 ¶ added in v0.3.0
GenerateV3 generates a version 3 UUID based on a namespace UUID and additional data.
func GenerateV4 ¶ added in v0.3.0
GenerateV4 generates a version 4 UUID.
If a nil reader is passed as argument, crypto/rand.Reader is used instead.
func GenerateV5 ¶ added in v0.3.0
GenerateV5 generates a version 5 UUID based on a namespace UUID and additional data.
func Parse ¶
Parse parses a UUID 36-byte slice encoded in hexadecimal and converts it to a 16-byte array.
func V4 ¶ added in v0.6.0
V4 returns a version 4 UUID or panics otherwise.
If a nil reader is passed as argument, crypto/rand.Reader is used instead.
func (UUID) MarshalBinary ¶
MarshalBinary implements binary marshaling.
func (UUID) MarshalJSON ¶
MarshalJSON implements JSON marshaling.
func (UUID) MarshalText ¶
MarshalText implements text marshaling.
func (*UUID) UnmarshalBinary ¶
UnmarshalBinary implements binary unmarshaling.
func (*UUID) UnmarshalJSON ¶
UnmarshalJSON implements JSON unmarshaling.
func (*UUID) UnmarshalText ¶
UnmarshalText implements text unmarshaling.
type Variant ¶
type Variant byte
Variant is a UUID variant as per the RFC 4122, § 4.1.1.
const ( // VariantNCS is a reserved variant for NCS backward compatibility. VariantNCS Variant = 0x00 // VariantRFC4122 is the current variant defined by the RFC 4122. VariantRFC4122 Variant = 0x80 // 10xxxxxx // VariantMicrosoft is a reserved variant for Microsoft Corporation backward compatibility. VariantMicrosoft Variant = 0xC0 // 110xxxxx // VariantUndefined is a reserved variant for future definition (still undefined). VariantUndefined Variant = 0xE0 // 111xxxxx )
type Version ¶
type Version byte
Version is a modifying byte.
const ( // VersionNone is an invalid UUID version. VersionNone Version = iota // Version1 is the version 1 of the UUID implementation. Version1 Version = iota << 4 // Version2 is the version 2 of the UUID implementation. Version2 // Version3 is the version 3 of the UUID implementation. Version3 // Version4 is the version 4 of the UUID implementation. Version4 // Version5 is the version 5 of the UUID implementation. Version5 )