mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-08-06 17:40:58 +00:00
16 lines
318 B
Go
16 lines
318 B
Go
// Copyright 2025 The Forgejo Authors
|
|
// SPDX-License-Identifier: MIT
|
|
package common
|
|
|
|
import (
|
|
"crypto/rand"
|
|
"encoding/hex"
|
|
)
|
|
|
|
func RandName(size int) (string, error) {
|
|
randBytes := make([]byte, size)
|
|
if _, err := rand.Read(randBytes); err != nil {
|
|
return "", err
|
|
}
|
|
return hex.EncodeToString(randBytes), nil
|
|
}
|