You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
322 B
25 lines
322 B
package util
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/bwmarrin/snowflake"
|
|
)
|
|
|
|
var node *snowflake.Node
|
|
|
|
func init() {
|
|
n, err := snowflake.NewNode(1)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
node = n
|
|
}
|
|
|
|
func GenCodeInt() int64 {
|
|
return node.Generate().Int64()
|
|
}
|
|
|
|
func GenCodeStr() string {
|
|
return node.Generate().String()
|
|
}
|