This commit is contained in:
laodaming
2023-06-27 15:26:23 +08:00
parent 3a2fb3bc5d
commit 9050b4ab0e
3 changed files with 18 additions and 23 deletions

View 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, ".", "")
}

View File

@@ -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
}