mirror of
https://github.com/akyaiy/GoSally-mvp.git
synced 2026-01-03 08:32:24 +00:00
19 lines
377 B
Go
19 lines
377 B
Go
package utils
|
|
|
|
import (
|
|
"crypto/rand"
|
|
"encoding/hex"
|
|
"errors"
|
|
|
|
"github.com/akyaiy/GoSally-mvp/core/config"
|
|
)
|
|
|
|
func NewUUID() (string, error) {
|
|
bytes := make([]byte, int(config.GetInternalConsts().GetUUIDLength()/2))
|
|
_, err := rand.Read(bytes)
|
|
if err != nil {
|
|
return "", errors.New("failed to generate UUID: " + err.Error())
|
|
}
|
|
return hex.EncodeToString(bytes), nil
|
|
}
|