uuid

package
v1.38.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2024 License: MIT Imports: 9 Imported by: 3

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

func ResemblesUUID

func ResemblesUUID(s string) bool

Determine if an input string resembles a UUID

Types

type UUID

type UUID [16]byte
var Zero UUID = [16]byte{}

func BaseFromTime

func BaseFromTime(aTime time.Time) UUID

UUIDBaseFromTime generates a new time based UUID (version 1) in the same manner as UUIDFromTime with the exception that the clock sequence component is zeroed. This allows for the construction of a time UUID that represents the lower bound of any other UUID that could be generated for the same time.

func FromBytes

func FromBytes(input []byte) (UUID, error)

func FromTime

func FromTime(aTime time.Time) UUID

UUIDFromTime 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, the given timestamp and a sequence number.

func New

func New() UUID

func Parse

func Parse(input string) (UUID, error)

func Random

func Random() UUID

func Time

func Time() 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) Compare

func (u UUID) Compare(c sort.Comparable) int

Lexically compare this UUID to another UUID

func (UUID) IsZero

func (u UUID) IsZero() bool

Does this UUID represent the zero value

func (UUID) MarshalBinary

func (u UUID) MarshalBinary() ([]byte, error)

func (UUID) MarshalJSON

func (u UUID) MarshalJSON() ([]byte, error)

func (UUID) MarshalText

func (u UUID) MarshalText() ([]byte, error)

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) Scan

func (v *UUID) Scan(src interface{}) error

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() int64

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

func (*UUID) UnmarshalBinary

func (u *UUID) UnmarshalBinary(data []byte) error

func (*UUID) UnmarshalJSON

func (u *UUID) UnmarshalJSON(data []byte) error

func (*UUID) UnmarshalText

func (u *UUID) UnmarshalText(data []byte) error

func (UUID) Value

func (v UUID) Value() (driver.Value, error)

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