docs/pkg/libcontainer/utils/utils.go

16 lines
286 B
Go

package utils
import (
"crypto/rand"
"encoding/hex"
"io"
)
func GenerateRandomName(prefix string, size int) (string, error) {
id := make([]byte, 32)
if _, err := io.ReadFull(rand.Reader, id); err != nil {
return "", err
}
return prefix + hex.EncodeToString(id)[:size], nil
}