mirror of
https://github.com/apricote/hcloud-upload-image.git
synced 2026-02-06 17:57:06 +00:00
refactor: yeet util/ subdirs
This commit is contained in:
parent
b6ae95f55b
commit
62578ad5c5
13 changed files with 10 additions and 10 deletions
18
randomid/randomid.go
Normal file
18
randomid/randomid.go
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
package randomid
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// From https://gitlab.com/hetznercloud/fleeting-plugin-hetzner/-/blob/0f60204582289c243599f8ca0f5be4822789131d/internal/utils/random.go
|
||||
|
||||
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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue