15 lines
241 B
Go
15 lines
241 B
Go
|
package id_generator
|
||
|
|
||
|
import (
|
||
|
"github.com/bwmarrin/snowflake"
|
||
|
)
|
||
|
|
||
|
func GenSnowFlakeId() (string, error) {
|
||
|
//暂时只用一个节点
|
||
|
n, err := snowflake.NewNode(1)
|
||
|
if err != nil {
|
||
|
return "", err
|
||
|
}
|
||
|
return n.Generate().Base58(), nil
|
||
|
}
|