id

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Format

func Format(value uint64) string

Format formats a numeric ID as a decimal string.

func MustRandom

func MustRandom(size int) string

MustRandom returns a URL-safe random string or panics.

func Random

func Random(size int) (string, error)

Random returns a URL-safe random string.

func RandomHex

func RandomHex(size int) (string, error)

RandomHex returns a hex random string.

Types

type Generator

type Generator interface {
	New(ctx context.Context) (uint64, error)
	String(ctx context.Context) (string, error)
}

Generator creates unique IDs.

type GeneratorFunc

type GeneratorFunc func(context.Context) (uint64, error)

GeneratorFunc adapts a function to Generator.

func (GeneratorFunc) New

func (fn GeneratorFunc) New(ctx context.Context) (uint64, error)

New creates a new ID.

func (GeneratorFunc) String

func (fn GeneratorFunc) String(ctx context.Context) (string, error)

String creates a new decimal string ID.

Jump to

Keyboard shortcuts

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