Debian Codegraph @

util/id_gennerator.go

raw symbols SCIP
1 package util
2
3 import (
4 "math/rand"
5 "time"
6 )
7
8 func init() {
9 rand.Seed(time.Now().UnixNano())
10 }
11
12 const (
13 chartIDSize = 12
14 )
15
16 // GenerateUniqueID generate the unique ID for each chart.
17 func GenerateUniqueID() string {
18 var b [chartIDSize]byte
19 for i := range b {
20 b[i] = randByte()
21 }
22 return string(b[:])
23 }
24
25 func randByte() byte {
26 c := 65 // A
27 if rand.Intn(10) > 5 {
28 c = 97 // a
29 }
30 return byte(c + rand.Intn(26))
31 }