fix
This commit is contained in:
13
utils/id_generator/pickup_track_num.go
Normal file
13
utils/id_generator/pickup_track_num.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package id_generator
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func GenPickUpTrackNum() string {
|
||||
a := fmt.Sprintf("%s%.8d", time.Now().Format("20060102150405.000"), rand.Intn(1000000))
|
||||
return strings.ReplaceAll(a, ".", "")
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
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