fix
This commit is contained in:
16
utils/snow_id_generator/snowflake.go
Normal file
16
utils/snow_id_generator/snowflake.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package snow_id_generator
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/bwmarrin/snowflake"
|
||||
"time"
|
||||
)
|
||||
|
||||
// 雪花算法生成id
|
||||
func GenSnowId() (string, error) {
|
||||
node, err := snowflake.NewNode(1)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return fmt.Sprintf("%s%s", time.Now().Format("20060102"), node.Generate().Base58()), nil
|
||||
}
|
||||
Reference in New Issue
Block a user