photoprism/pkg/rnd/ppid.go
Michael Mayer 54d33e2a43 Shorten unique IDs
Signed-off-by: Michael Mayer <michael@liquidbytes.net>
2020-01-23 09:50:43 +01:00

17 lines
342 B
Go

package rnd
import (
"strconv"
"time"
)
// PPID returns a unique id with prefix as string.
func PPID(prefix rune) string {
result := make([]byte, 0, 16)
result = append(result, byte(prefix))
result = append(result, strconv.FormatInt(time.Now().UTC().Unix(), 36)[0:6]...)
result = append(result, Token(9)...)
return string(result)
}