bwmarrin / snowflake

A simple to use Go (golang) package to generate or parse Twitter snowflake IDs
BSD 2-Clause "Simplified" License
2.98k stars 371 forks source link

How can i reduce the length of id? #29

Closed jonathanchoo519 closed 3 years ago

jonathanchoo519 commented 3 years ago

Hi

I generate ids by default setting got the length is 19, how can i reduce the length down to 15?

thx

vkstack commented 3 years ago

this gives you 64 bit number, There is no way you can short this, unless you write your own.

if you convert it to base62 you ll have a shorter id for sure

bwmarrin commented 3 years ago

There are several methods in this package you can use to reduce the number of characters an ID uses. Like the Base58 method here, https://github.com/bwmarrin/snowflake/blob/master/snowflake.go#L250.