uuid

package
v0.0.0-...-5f226fc Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 8 Imported by: 58

Documentation

Overview

Package uuid implements UUID v4 based on RFC4122.

Index

Constants

This section is empty.

Variables

View Source
var Error = errs.Class("uuid")

Error is the default error class for uuid.

Functions

func SortAscending

func SortAscending(uuids []UUID)

SortAscending orders a slice of UUIDs from low to high.

Types

type NullUUID

type NullUUID struct {
	UUID  UUID
	Valid bool // Valid is true if UUID is not NULL
}

NullUUID represents a UUID that may be null. NullUUID implements the Scanner interface so it can be used as a scan destination, similar to sql.NullString.

func (*NullUUID) Scan

func (n *NullUUID) Scan(value interface{}) error

Scan implements sql.Scanner interface.

func (NullUUID) Value

func (n NullUUID) Value() (driver.Value, error)

Value implements sql/driver.Valuer interface.

type UUID

type UUID [16]byte

UUID is big-endian encoded UUID.

UUID can be of any version or variant.

func FromBytes

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

FromBytes converts big-endian raw-bytes to an UUID.

FromBytes allows for any version or variant of an UUID.

func FromString

func FromString(s string) (UUID, error)

FromString parses "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" and "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" string.

FromString allows for any version or variant of an UUID.

func Max

func Max() UUID

Max returns the maximum value of a UUID.

func New

func New() (UUID, error)

New returns a random UUID (version 4 variant 2).

func (UUID) Bytes

func (uuid UUID) Bytes() []byte

Bytes returns raw bytes of the uuid.

func (UUID) Compare

func (uuid UUID) Compare(other UUID) int

Compare returns an integer comparing uuid and other lexicographically. The result will be 0 if uuid==other, -1 if uuid < other, and +1 if uuid > other.

func (*UUID) DecodeSpanner

func (uuid *UUID) DecodeSpanner(val any) (err error)

DecodeSpanner implements spanner.Decoder.

func (UUID) EncodeSpanner

func (uuid UUID) EncodeSpanner() (any, error)

EncodeSpanner implements spanner.Encoder.

func (UUID) IsZero

func (uuid UUID) IsZero() bool

IsZero returns true when all bytes in uuid are 0.

func (UUID) Less

func (uuid UUID) Less(other UUID) bool

Less returns whether uuid is smaller than other in lexicographic order.

func (UUID) Marshal

func (uuid UUID) Marshal() ([]byte, error)

Marshal serializes uuid.

func (UUID) MarshalJSON

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

MarshalJSON marshals UUID in `"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"` form.

func (UUID) MarshalText

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

MarshalText marshals UUID in `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx` form.

func (*UUID) MarshalTo

func (uuid *UUID) MarshalTo(data []byte) (n int, err error)

MarshalTo serializes uuid into the passed byte slice.

func (*UUID) Scan

func (uuid *UUID) Scan(value interface{}) error

Scan implements sql.Scanner interface.

func (UUID) Size

func (uuid UUID) Size() int

Size returns the length of uuid (implements gogo's custom type interface).

func (UUID) String

func (uuid UUID) String() string

String returns uuid in "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" format.

func (*UUID) Unmarshal

func (uuid *UUID) Unmarshal(data []byte) error

Unmarshal deserializes uuid.

func (*UUID) UnmarshalJSON

func (uuid *UUID) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals UUID from `"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"`.

func (*UUID) UnmarshalText

func (uuid *UUID) UnmarshalText(b []byte) error

UnmarshalText unmarshals UUID from `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`.

func (UUID) Value

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

Value implements sql/driver.Valuer interface.

Jump to

Keyboard shortcuts

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