ids

package
v2.5.6 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllToString

func AllToString(ids []Id) []string

AllToString converts a slice of Ids into a slice of strings

func Compare

func Compare(id Id, other Id) int

Compare compares two Ids

func IsEmpty

func IsEmpty(id Id) bool

func IsNotEmpty

func IsNotEmpty(id Id) bool

func ToBytes

func ToBytes(id Id) []byte

ToBytes converts an Id into a byte slice

Types

type Id

type Id = uuid.UUID

Id is a generic identifier for entities

func Empty

func Empty() Id

func FromBytes

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

FromBytes converts a byte slice into an Id.

func MustParse

func MustParse(id string) Id

MustParse parses a string into an Id. If the string is empty, returns an empty Id. If the string is not a valid Id, panics.

func New

func New() Id

func NewID

func NewID(values ...any) Id

NewID computes a UUID string hashing the provided values

func OrDefault

func OrDefault(id Id, defaultId Id) Id

OrDefault returns the defaultId if id is empty, otherwise returns id

func OrNew

func OrNew(id Id) Id

OrNew returns a new Id if id is empty, otherwise returns id

func Parse

func Parse(id string) (Id, error)

Parse parses a string into an Id. If the string is empty, returns an empty Id.

func SelfOrNew

func SelfOrNew(id Id) Id

SelfOrNew returns a new Id if id is empty, otherwise returns id Deprecated: use OrNew instead

Jump to

Keyboard shortcuts

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