uuid

package
v0.9.7 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2025 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLength  = errors.New(`invalid UUID length`)
	ErrInvalidVersion = errors.New(`invalid UUID version`)
)

Functions

This section is empty.

Types

type IDType

type IDType uint8

type UUID

type UUID [16]byte

UUID is a 128-bit identifier.

func FromString

func FromString(s string) (UUID, error)

Checks version, passes off to version specific parser

func New

func New(typeID ...IDType) UUID

New creates a new UUID with an optional typeID.

func (UUID) IsNil

func (u UUID) IsNil() bool

IsNil indicates whether the UUID is the zero value.

func (UUID) MarshalText

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

MarshalText implements encoding.TextMarshaler.

func (UUID) Sequence

func (u UUID) Sequence() uint8

Sequence returns the 8-bit sequence counter.

func (UUID) String

func (u UUID) String() string

String returns the UUID as a formatted string.

func (UUID) Time

func (u UUID) Time() time.Time

Time returns the time the UUID was generated.

func (UUID) Timestamp

func (u UUID) Timestamp() uint64

Timestamp returns the 52-bit timestamp (microseconds since Jan 1, 2025).

func (UUID) Type

func (u UUID) Type() IDType

Type returns the 8-bit type identifier.

func (*UUID) UnmarshalText

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

UnmarshalText implements encoding.TextUnmarshaler.

func (UUID) Unused

func (u UUID) Unused() uint64

Unused returns the 56-bit unused field.

func (UUID) Version

func (u UUID) Version() uint8

Version returns the 4-bit version.

type UUIDGenerator

type UUIDGenerator struct {
	// contains filtered or unexported fields
}

UUIDGenerator is responsible for generating unique UUIDs.

func (*UUIDGenerator) NewUUID

func (g *UUIDGenerator) NewUUID(typeID IDType) UUID

NewUUID generates a new UUID for the given typeID (0 ≤ typeID < 256).

Jump to

Keyboard shortcuts

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