Documentation
¶
Index ¶
- Constants
- Variables
- func Equal(u1, u2 UUID) bool
- func IsValid(in interface{}) bool
- func NewString() string
- type NullUUID
- type UUID
- func (u UUID) Bytes() []byte
- func (u *UUID) Equal(u2 UUID) bool
- func (u UUID) MarshalJSON() ([]byte, error)
- func (u *UUID) Scan(src interface{}) error
- func (u UUID) String() string
- func (u UUID) ToBytes() []byte
- func (u *UUID) UnmarshalBinary(data []byte) error
- func (u *UUID) UnmarshalJSON(b []byte) error
- func (u *UUID) UnmarshalText(text string) error
- func (u UUID) Value() (driver.Value, error)
- func (u UUID) Variant() byte
- func (u UUID) Version() byte
Constants ¶
const ( // V4 Represents the UUID version 4 V4 byte = 0x04 // V5 Represents the UUID version 5 V5 byte = 0x05 )
const ( // VariantNCS Represents the UUID variant NCS VariantNCS byte // VariantRFC4122 Represents the UUID variant RFC4122 VariantRFC4122 // VariantMicrosoft Represents the UUID variant Microsoft VariantMicrosoft // VariantFuture Represents the UUID variant Future VariantFuture )
Variables ¶
var Nil = UUID{}
Nil is the Nil UUID.
Functions ¶
Types ¶
type NullUUID ¶
NullUUID is a nullable UUID.
func (NullUUID) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
func (*NullUUID) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
type UUID ¶
type UUID [16]byte
UUID is a 128 bit (16 byte) Universal Unique IDentifier.
var ( // NSDNS is the IETF namespace for the DNS. NSDNS UUID = Parse("6ba7b810-9dad-11d1-80b4-00c04fd430c8") // NSURL is the IETF namespace for the URL. NSURL UUID = Parse("6ba7b811-9dad-11d1-80b4-00c04fd430c8") // NSOID is the IETF namespace for the OID. NSOID UUID = Parse("6ba7b812-9dad-11d1-80b4-00c04fd430c8") // NSX500 is the IETF namespace for the X500. NSX500 UUID = Parse("6ba7b814-9dad-11d1-80b4-00c04fd430c8") )
func New ¶
func New() UUID
New returns a new UUID based on the string input. It returns Nil if the input is not a valid UUID.
func NewV4 ¶
func NewV4() UUID
NewV4 returns a new random UUID. It returns Nil if the input is not a valid UUID.
func NewV5 ¶
NewV5 returns a new UUID based on the SHA-1 hash of the namespace UUID and name. It returns Nil if the input is not a valid UUID.
func Parse ¶
func Parse(in interface{}) UUID
Parse decodes s string into a UUID or returns NilUUID if the string is invalid. formats: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.
func (UUID) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
func (*UUID) UnmarshalBinary ¶
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
func (*UUID) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
func (*UUID) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.