reqid

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RequestID

func RequestID(c context.Context) (string, bool)

Types

type ReqID

type ReqID string
const RequestIDKey ReqID = "request_id"

func NewRequestID

func NewRequestID() ReqID

NewRequestID creates and returns a 26-character base32 (RFC4648, no padding) string representing 128 bits composed of: - 48-bit big-endian timestamp (milliseconds since epoch) -> 6 bytes - 80-bit cryptographically secure random bytes -> 10 bytes

The resulting 16 bytes are base32-encoded without padding, producing 26 chars. This layout keeps IDs roughly sortable by creation time while maintaining strong randomness. If the crypto RNG fails, a time-seeded math/rand fallback is used to ensure an ID is still produced.

Jump to

Keyboard shortcuts

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