mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
17 lines
248 B
Go
17 lines
248 B
Go
|
package utils
|
||
|
|
||
|
import (
|
||
|
"io"
|
||
|
"crypto/rand"
|
||
|
"encoding/hex"
|
||
|
)
|
||
|
|
||
|
func RandomString() string {
|
||
|
id := make([]byte, 32)
|
||
|
_, err := io.ReadFull(rand.Reader, id)
|
||
|
if err != nil {
|
||
|
panic(err) // This shouldn't happen
|
||
|
}
|
||
|
return hex.EncodeToString(id)
|
||
|
}
|