feat(uuid):完成UUID和短UUID生成功能。

This commit is contained in:
徐涛
2023-07-12 21:57:59 +08:00
parent 2a2283ec4c
commit 4229c1a7a5
5 changed files with 89 additions and 2 deletions

19
serial_code/uuid/uuid.go Normal file
View File

@@ -0,0 +1,19 @@
// 提供UUID v4生成功能以及基于UUID v4生成短UUID的功能。
package uuid
import (
"encoding/hex"
"github.com/google/uuid"
)
// 生成一个UUID v4字节数组。
func New() []byte {
newID := uuid.New()
return newID[:]
}
// 生成一个UUID v4字符串。
func NewString() string {
return hex.EncodeToString(New())
}