PCM/common/uniqueid/uniqueid.go

24 lines
361 B
Go
Raw Normal View History

2023-02-16 09:19:39 +08:00
package uniqueid
import (
"github.com/sony/sonyflake"
"github.com/zeromicro/go-zero/core/logx"
)
var flake *sonyflake.Sonyflake
func init() {
flake = sonyflake.NewSonyflake(sonyflake.Settings{})
}
func GenId() int64 {
id, err := flake.NextID()
if err != nil {
logx.Severef("flake NextID failed with %s \n", err)
panic(err)
}
return int64(id)
}