雪花算法
package snowflake
import (
"time"
sf "github.com/bwmarrin/snowflake"
)
var node *sf.Node
func Init(startTime string, machineID int64) (err error) {
var st time.Time
st, err = time.Parse("2006-01-02", startTime)
if err != nil {
return
}
sf.Epoch = st.UnixNano() / 1000000
node, err = sf.NewNode(machineID)
return
}
func GetID() int64 {
return node.Generate().Int64()
}
标签:node,return,err,雪花,st,算法,time,sf
From: https://www.cnblogs.com/suehoo/p/17017152.html