Documentation
¶
Overview ¶
Snowflake ID generation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Id ¶
func Id() (id string)
Generate Snowflake Id
The id consists of [64 bits long] + [6 digits machine_code] The 64 bits long consists of: [sign bit (1 bit)] + [timestamp (49 bits, ~1487.583 years)] + [sequenceNo (14 bits, 0~16383)]
The max value of Long is 9223372036854775807, which is a string with 19 characters, so the generated id will be of at most 25 characters ¶
This func is thread-safe
func SetMachineCode ¶
Overwrite the randomly generated machine code, machine code must be between 0 and 999999, at most 6 digits.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.