Files
GoSally/core/utils/uuid.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
}