hcloud-upload-image/util/randomid/randomid.go

17 lines
274 B
Go
Raw Normal View History

2024-04-29 21:00:04 +02:00
package randomid
import (
"crypto/rand"
"encoding/hex"
"fmt"
)
func Generate() (string, error) {
b := make([]byte, 4)
_, err := rand.Read(b)
if err != nil {
return "", fmt.Errorf("failed to generate random string: %w", err)
}
return hex.EncodeToString(b), nil
}