feat(uuid):完成UUID和短UUID生成功能。
This commit is contained in:
19
serial_code/uuid/uuid.go
Normal file
19
serial_code/uuid/uuid.go
Normal 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())
|
||||
}
|
Reference in New Issue
Block a user