Add generate
This commit is contained in:
parent
68b971f65a
commit
4de1344512
1 changed files with 24 additions and 0 deletions
24
internal/generate/unique.go
Normal file
24
internal/generate/unique.go
Normal file
|
@ -0,0 +1,24 @@
|
|||
package generate
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"encoding/hex"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
func UUID() string {
|
||||
// must be addressable
|
||||
u := uuid.New()
|
||||
|
||||
return hex.EncodeToString(u[:])
|
||||
}
|
||||
|
||||
func Hex(l int) string {
|
||||
b := make([]byte, l)
|
||||
if _, err := rand.Read(b); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return hex.EncodeToString(b)
|
||||
}
|
Loading…
Reference in a new issue