Documentation
¶
Overview ¶
Package identifier provides a simple, thread-safe, and efficient way to generate unique identifiers. It offers straightforward functions to get unique strings or numbers without requiring any configuration.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateNumber ¶ added in v1.1.0
GenerateNumber generates a new identifier number using the default generator.
func GenerateString ¶ added in v1.1.0
GenerateString generates a new identifier string using the default generator.
Types ¶
type Generator ¶
type Generator interface {
// Name returns the unique name of the generator algorithm.
Name() string
// GenerateString generates a new identifier as a string.
GenerateString() (string, error)
// GenerateNumber generates a new identifier as an int64.
// Note: May not be supported by all generators.
GenerateNumber() (int64, error)
// Validate checks if a provided identifier is valid.
// The id can be a string or int64, depending on the generator.
Validate(id any) bool
}
Generator defines the interface for an identifier generation algorithm. This is intended for advanced users who want to implement or use custom generators.
Click to show internal directories.
Click to hide internal directories.