Documentation
¶
Overview ¶
Package snowflake provides a unique ID generation based on Twitter Snowflake algorithm.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NumberSnowflake ¶
type NumberSnowflake struct {
*Snowflake
}
func NewNumber ¶
func NewNumber(opts ...Option) *NumberSnowflake
func (NumberSnowflake) Generate ¶
func (n NumberSnowflake) Generate() int64
func (NumberSnowflake) Validate ¶
func (n NumberSnowflake) Validate(t int64) bool
type Snowflake ¶
type Snowflake struct {
// contains filtered or unexported fields
}
Snowflake represents a Snowflake generator with a unique generator.
func (Snowflake) GenerateNumber ¶
GenerateNumber generates a new Snowflake ID as an int64.
func (Snowflake) GenerateString ¶
GenerateString generates a new Snowflake ID as a string.
func (Snowflake) ValidateNumber ¶
ValidateNumber checks if the provided ID is a valid Snowflake ID (int64).
func (Snowflake) ValidateString ¶
ValidateString checks if the provided ID is a valid Snowflake ID (string).
type StringSnowflake ¶
type StringSnowflake struct {
*Snowflake
}
func NewString ¶
func NewString(opts ...Option) *StringSnowflake
func (StringSnowflake) Generate ¶
func (s StringSnowflake) Generate() string
func (StringSnowflake) Validate ¶
func (s StringSnowflake) Validate(id string) bool
Click to show internal directories.
Click to hide internal directories.