uuid

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UUID_VARIANT_RESERVED_NCS_BACKWARD_COMPATIBLE = 0x00
	UUID_VARIANT_RESERVED_RFC_4122_NAMESPACE_DNS  = 0x01
	UUID_VARIANT_RESERVED_RFC_4122_NAMESPACE_URL  = 0x02
	UUID_VARIANT_RESERVED_RFC_4122_NAMESPACE_OID  = 0x03
	UUID_VARIANT_RESERVED_RFC_4122_NAMESPACE_X500 = 0x04
	UUID_VARIANT_RESERVED_FUTURE_USE              = 0x05
	UUID_VARIANT_RESERVED_FOR_NCS_COMPATIBILITY   = 0x06
	UUID_VARIANT_RESERVED_FOR_FUTURE_USE          = 0x07
)

Variables

This section is empty.

Functions

This section is empty.

Types

type UUID

type UUID struct {
	// Version is the version of the UUID
	Version uint8
	// Variant is the variant of the UUID
	Variant uint8

	// Data is the data of the UUID
	Data [15]byte
}

UUID represents a UUID structure

func (*UUID) FromString

func (u *UUID) FromString(s string) error

FromString parses a UUID string in the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx and returns a UUID structure.

Parameters:

  • s: A string representation of the UUID

Returns:

  • An error if the string is not a valid UUID format

func (*UUID) Marshal

func (u *UUID) Marshal() ([]byte, error)

Marshal converts a UUID structure into a 16-byte array

Returns:

  • A byte slice containing the UUID's 16 bytes
  • An error if the UUID is invalid or the conversion fails

func (*UUID) String

func (u *UUID) String() string

String returns a string representation of the UUID in the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, where x is a hexadecimal digit.

Returns:

  • A string representation of the UUID

func (*UUID) Unmarshal

func (u *UUID) Unmarshal(marshalledData []byte) (int, error)

Unmarshal converts a 16-byte array into a UUID structure

Parameters:

  • data: A byte slice containing the UUID's 16 bytes

Returns:

  • The number of bytes read
  • An error if the UUID is invalid or the conversion fails

type UUIDInterface

type UUIDInterface interface {
	// Marshal converts a UUID structure into a 16-byte array
	Marshal() ([]byte, error)
	// Unmarshal converts a 16-byte array into a UUID structure
	Unmarshal(data []byte) (int, error)
	// FromString parses a UUID string in the format "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
	FromString(s string) error
	// String returns the string representation of the UUID
	String() string
}

UUIDInterface is an interface that defines the methods for a UUID

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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