id

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package id generates prefixed NanoIDs — short, URL-safe, collision-resistant public identifiers (Stripe-style: "sess_V1StGXR8Zx7pq"). They are the primary keys for runtime entities, friendlier to read and copy than a UUID while carrying far more entropy than the old randHex(4) handles (which collided around ~65k rows).

Index

Constants

View Source
const Size = 16

Size is the number of random characters after the prefix. 16 chars over a 64-symbol alphabet is 96 bits of entropy — collision-safe well past any realistic row count.

Variables

This section is empty.

Functions

func NanoID

func NanoID(n int) string

NanoID returns a bare random id of n characters.

func New

func New(prefix string) string

New returns a prefixed id: "<prefix>_<nanoid>", e.g. New("sess") -> "sess_V1StGXR8Zx7pq".

func Prefix

func Prefix(id string) string

Prefix returns the type prefix of an id (the part before the first underscore), or "".

Types

This section is empty.

Jump to

Keyboard shortcuts

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