chore(refactor): add common.RandName to keep name generation DRY

This commit is contained in:
Earl Warren 2025-07-12 18:53:25 +02:00
parent 7eb547faa5
commit 6e59f129c1
4 changed files with 25 additions and 14 deletions

16
act/common/randname.go Normal file
View file

@ -0,0 +1,16 @@
// 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
}