Documentation ¶
Index ¶
Constants ¶
const Size = 16
Size is the size, in bytes, of a UUID.
const StringSize = 36
StringSize is the size, in bytes, of a UUID string with hyphens.
Variables ¶
var Empty = UUID{}
Empty returns the empty UUID - that is, a UUID with all 128-bits as zero. Contrary to popular belief, the Empty UUID can never be generated, even under Version 4 UUIDs.
var ErrInvalidSize = errors.New("the provided UUID was not 16 bytes in length")
ErrInvalidSize is returned when parsing a UUID that is not 16 bytes in length.
Functions ¶
This section is empty.
Types ¶
type UUID ¶
UUID stores a single 128-bit UUID.
func New ¶
func New() UUID
New creates a new Version 4, Variant 1 UUID using the standard library CSPRNG. It is assumed that this CSPRNG is always available to ease error checking when generating UUIDs. If random bytes cannot be read, this call will panic.
func NewFrom ¶
NewFrom creates a new Version 4, Variant 1 UUID using the provided source of random numbers.
func Parse ¶
Parse parses the provided UUID string to a UUID structure. Parse allows UUIDs with different versions and variants.
func (UUID) MarshalJSON ¶
MarshalJSON marshals the UUID into a JSON string literal.
func (UUID) String ¶
String converts the UUID to the standard UUID string representation with hyphens.
func (*UUID) UnmarshalJSON ¶
UnmarshalJSON unmarshals the provided JSON literal into the UUID.