xuid

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2022 License: BSD-3-Clause Imports: 4 Imported by: 9

README

GoDoc

XUID

XUID is an ID that contains the exact same number of bits as a UUID, adds a type prefix, and is encoded in a string that will not be larger than 36 characters.

This is achieved by using base32 instead of base16. Base32 still only uses one set of alphabetic characters, allowing caseless matches.

Type

The type is a up to 5 characters long code that specifies what kind of object the ID is of. It is used to allow easy identification of an ID, either by humans or automated code.

Examples

  • UUID 3f1b4d37-34d9-46c6-b546-a57c5f736d22 with type shell becomes shell-h4nu2n-zu3f-dmnn-kguv-6f643nei
  • UUID 00000000-0000-0000-0000-000000000000 with type null becomes null-aaaaaa-aaaa-aaaa-aaaa-aaaaaaaa

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type XUID

type XUID struct {
	Prefix string
	UUID   uuid.UUID
}

func FromUUID

func FromUUID(u uuid.UUID, prefix string) (*XUID, error)

func Must

func Must(x *XUID, err error) *XUID

func MustParse

func MustParse(s string) *XUID

func MustParseUUID

func MustParseUUID(inputUuid, prefix string) *XUID

func New

func New(prefix string) *XUID

func NewRandom

func NewRandom(prefix string) (*XUID, error)

func Parse

func Parse(s string) (*XUID, error)

func ParseUUID

func ParseUUID(inputUuid, prefix string) (*XUID, error)

func (*XUID) Scan

func (x *XUID) Scan(value any) error

Scan sets the value of the XUID to the passed data, parsing it as needed.

func (XUID) String

func (x XUID) String() string

func (*XUID) ToUUID

func (x *XUID) ToUUID() string

Jump to

Keyboard shortcuts

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