323d495840
Signed-off-by: Michael Mayer <michael@photoprism.app>
21 lines
417 B
Go
21 lines
417 B
Go
package rnd
|
|
|
|
import (
|
|
"strconv"
|
|
"time"
|
|
)
|
|
|
|
const (
|
|
PrefixNone = byte(0)
|
|
PrefixMixed = byte('*')
|
|
)
|
|
|
|
// 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)
|
|
}
|