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

Why don't we use the method init() anywhere? #27

Closed khiemfle closed 3 years ago

khiemfle commented 3 years ago

May I ask why don't we use the method init() anywhere?

https://github.com/bwmarrin/snowflake/blob/c09e69ae59935edf6d85799e858c26de86b04cb3/snowflake.go#L59

bwmarrin commented 3 years ago

init() is a magic function of sorts that Go uses on it's own. That function is called by the go runtime when the application launches. It just does some basic initialization that needs to be done.