fusenapi/utils/id_generator/snowflake.go

15 lines
241 B
Go
Raw Normal View History

2023-06-28 09:05:31 +00:00
package id_generator
import (
"github.com/bwmarrin/snowflake"
)
func GenSnowFlakeId() (string, error) {
//暂时只用一个节点
n, err := snowflake.NewNode(1)
if err != nil {
return "", err
}
return n.Generate().Base58(), nil
}