Back to

package uuid

Latest Go to latest
Published: Oct 20, 2018 | License: MIT | Module:


Package uuid provides implementation of Universally Unique Identifier (UUID). Supported versions are 1, 3, 4 and 5 (as specified in RFC 4122) and version 2 (as specified in DCE 1.1).



const (
	V1 = guuid.V1
	V2 = guuid.V2
	V3 = guuid.V3
	V4 = guuid.V4
	V5 = guuid.V5

UUID versions

const (
	VariantNCS       = guuid.VariantNCS
	VariantRFC4122   = guuid.VariantRFC4122
	VariantMicrosoft = guuid.VariantMicrosoft
	VariantFuture    = guuid.VariantFuture

UUID layout variants.

const (
	DomainPerson = guuid.DomainPerson
	DomainGroup  = guuid.DomainGroup
	DomainOrg    = guuid.DomainOrg

UUID DCE domains.

const Size = guuid.Size

Size of a UUID in bytes.


var (
	NamespaceDNS  = guuid.NamespaceDNS
	NamespaceURL  = guuid.NamespaceURL
	NamespaceOID  = guuid.NamespaceOID
	NamespaceX500 = guuid.NamespaceX500

Predefined namespace UUIDs.

var FromBytes = guuid.FromBytes

FromBytes returns UUID converted from raw byte slice input. It will return error if the slice isn't 16 bytes long.

var FromBytesOrNil = guuid.FromBytesOrNil

FromBytesOrNil returns UUID converted from raw byte slice input. Same behavior as FromBytes, but returns a Nil UUID on error.

var FromString = guuid.FromString

FromString returns UUID parsed from string input. Input is expected in a form accepted by UnmarshalText.

var FromStringOrNil = guuid.FromStringOrNil

FromStringOrNil returns UUID parsed from string input. Same behavior as FromString, but returns a Nil UUID on error.

var NewV1 = guuid.NewV1

NewV1 returns UUID based on current timestamp and MAC address.

var NewV2 = guuid.NewV2

NewV2 returns DCE Security UUID based on POSIX UID/GID.

var NewV3 = guuid.NewV3

NewV3 returns UUID based on MD5 hash of namespace UUID and name.

var NewV4 = guuid.NewV4

NewV4 returns random generated UUID.

var NewV5 = guuid.NewV5

NewV5 returns UUID based on SHA-1 hash of namespace UUID and name.

var Nil = guuid.Nil

Nil is special form of UUID that is specified to have all 128 bits set to zero.

type Generator

type Generator = guuid.Generator

Generator provides interface for generating UUIDs.

type NullUUID

type NullUUID = guuid.NullUUID

NullUUID can be used with the standard sql package to represent a UUID value that can be NULL in the database

type UUID

type UUID = guuid.UUID

UUID representation compliant with specification described in RFC 4122.

func Must

func Must(u UUID, err error) UUID

Must is a helper that wraps a call to a function returning (UUID, error) and panics if the error is non-nil. It is intended for use in variable initializations such as

var packageUUID = uuid.Must(uuid.FromString("123e4567-e89b-12d3-a456-426655440000"));
Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
f or F : Jump to identifier