1234567891011121314151617181920212223242526 |
- package lxzap
- import (
- "fmt"
- "github.com/bwmarrin/snowflake"
- )
- var node *snowflake.Node
- func initSnow() {
- var err error
- node, err = snowflake.NewNode(1)
- if err != nil {
- panic(err.Error())
- return
- }
- fmt.Println("雪花算法初始化成功")
- }
- func NewUUID() (id uint) {
- id = uint(node.Generate().Int64())
- return
- }
- func init() {
- initSnow()
- }
|