2022-04-15 09:42:07 +02:00
|
|
|
package rnd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strconv"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
2022-09-30 00:42:19 +02:00
|
|
|
const (
|
|
|
|
PrefixNone = byte(0)
|
|
|
|
PrefixMixed = byte('*')
|
|
|
|
)
|
|
|
|
|
2022-04-15 09:42:07 +02:00
|
|
|
// GenerateUID returns a unique id with prefix as string.
|
|
|
|
func GenerateUID(prefix byte) string {
|
|
|
|
result := make([]byte, 0, 16)
|
|
|
|
result = append(result, prefix)
|
|
|
|
result = append(result, strconv.FormatInt(time.Now().UTC().Unix(), 36)[0:6]...)
|
|
|
|
result = append(result, GenerateToken(9)...)
|
|
|
|
|
|
|
|
return string(result)
|
|
|
|
}
|