uuid

package module
v0.0.0-...-a0b1148 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 4, 2014 License: BSD-3-Clause Imports: 7 Imported by: 61

Documentation

Overview

Package uuid can be used to generate and parse universally unique identifiers, a standardized format in the form of a 128 bit number.

http://tools.ietf.org/html/rfc4122

Index

Constants

View Source
const (
	VariantNCSCompat = 0
	VariantIETF      = 2
	VariantMicrosoft = 6
	VariantFuture    = 7
)

Variables

This section is empty.

Functions

This section is empty.

Types

type UUID

type UUID [16]byte

func FromBytes

func FromBytes(input []byte) UUID

FromBytes converts a raw byte slice to an UUID. It will panic if the slice isn't exactly 16 bytes long.

func NewRandom

func NewRandom() UUID

NewRandom generates a totally random UUID (version 4) as described in RFC 4122.

func NewTime

func NewTime() UUID

NewTime generates a new time based UUID (version 1) as described in RFC 4122. This UUID contains the MAC address of the node that generated the UUID, a timestamp and a sequence number.

func Parse

func Parse(input string) (UUID, error)

Parse parses a 32 digit hexadecimal number (that might contain hyphens) representing an UUID.

func (UUID) Bytes

func (u UUID) Bytes() []byte

Bytes returns the raw byte slice for this UUID. A UUID is always 128 bits (16 bytes) long.

func (UUID) Node

func (u UUID) Node() []byte

Node extracts the MAC address of the node who generated this UUID. It will return nil if the UUID is not a time based UUID (version 1).

func (UUID) String

func (u UUID) String() string

String returns the UUID in it's canonical form, a 32 digit hexadecimal number in the form of xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.

func (UUID) Time

func (u UUID) Time() time.Time

Time is like Timestamp, except that it returns a time.Time.

func (UUID) Timestamp

func (u UUID) Timestamp() uint64

Timestamp extracts the timestamp information from a time based UUID (version 1).

func (UUID) Variant

func (u UUID) Variant() int

Variant returns the variant of this UUID. This package will only generate UUIDs in the IETF variant.

func (UUID) Version

func (u UUID) Version() int

Version extracts the version of this UUID variant. The RFC 4122 describes five kinds of UUIDs.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL