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.
29 lines
377 B
29 lines
377 B
2 years ago
|
package utils
|
||
|
|
||
|
import (
|
||
|
"github.com/bwmarrin/snowflake"
|
||
|
)
|
||
|
|
||
|
func init() {
|
||
|
var err error
|
||
|
idGenerator, err = snowflake.NewNode(getNodeNum())
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func getNodeNum() int64 {
|
||
|
return 1
|
||
|
}
|
||
|
|
||
|
var idGenerator *snowflake.Node
|
||
|
|
||
|
func GenID() string {
|
||
|
return idGenerator.Generate().String()
|
||
|
}
|
||
|
|
||
|
func GenIDs(count int) []string {
|
||
|
//impl
|
||
|
return []string{}
|
||
|
}
|