ids

package
v0.2.49 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: GPL-2.0, GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package ids provides random identifier generation for stored records. All callers share the same entropy-minting logic; encoding and length are parameterised so each domain keeps its existing format.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(byteLen int, enc Encoding) string

New returns a random identifier. byteLen controls entropy (output length is ceil(byteLen*8/5) characters). Panics if crypto/rand fails.

func NewE

func NewE(byteLen int, enc Encoding) (string, error)

NewE is like New but returns an error instead of panicking when crypto/rand fails. Prefer this in library code where the caller can handle the failure gracefully.

func NewMessageID

func NewMessageID() string

NewMessageID returns a UUIDv7 (RFC 9562): time-ordered, globally unique, standard format.

func NewMessageIDE

func NewMessageIDE() (string, error)

NewMessageIDE is like NewMessageID but returns an error instead of panicking when crypto/rand fails.

Types

type Encoding

type Encoding int

Encoding selects the base32 variant used for the output string.

const (
	// HexUpper uses RFC 4648 base32hex (0-9 A-V), uppercase, no padding.
	HexUpper Encoding = iota
	// StdLower uses RFC 4648 base32 standard (a-z 2-7), lowercase, no padding.
	StdLower
)

Jump to

Keyboard shortcuts

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