Documentation
¶
Overview ¶
Package nextid generates the next task ID from existing ID lists.
It supports sequential, prefixed, random, and ULID formats while preserving common prefixes and zero-padding patterns.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GeneratePrefixed ¶
GeneratePrefixed produces the next sequential ID with the given prefix. It filters existing IDs by prefix, finds the max numeric suffix, and returns prefix + zero-padded(max+1).
func GenerateRandom ¶
GenerateRandom produces a random base-36 alphanumeric lowercase ID of the given length. It retries on collision with existingIDs (max 100 attempts).
func GenerateULID ¶
GenerateULID produces a ULID: 48-bit millisecond timestamp + 80-bit crypto random, encoded as 26 Crockford Base32 characters (lowercase). When length > 0 and < 26, the result is truncated to that length. It retries on collision with existingIDs (max 100 attempts).
Types ¶
type Result ¶
type Result struct {
NextID string `json:"next_id" yaml:"next_id"`
MaxID string `json:"max_id" yaml:"max_id"`
Prefix string `json:"prefix" yaml:"prefix"`
Padding int `json:"padding" yaml:"padding"`
Total int `json:"total" yaml:"total"`
}
Result holds the computed next ID and related metadata.