first commit
This commit is contained in:
20
internal/pkg/snowflake/snowflake.go
Normal file
20
internal/pkg/snowflake/snowflake.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package snowflake
|
||||
|
||||
import (
|
||||
"github.com/bwmarrin/snowflake"
|
||||
)
|
||||
|
||||
var node *snowflake.Node
|
||||
|
||||
func Init() error {
|
||||
n, err := snowflake.NewNode(1)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
node = n
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetId() int64 {
|
||||
return node.Generate().Int64()
|
||||
}
|
||||
Reference in New Issue
Block a user