Paperclip/pkg/internal/services/random_id.go
2024-08-20 17:08:40 +08:00

16 lines
304 B
Go

package services
import (
"math/rand"
)
var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
func RandString(length int) string {
builder := make([]rune, length)
for i := range builder {
builder[i] = letters[rand.Intn(len(letters))]
}
return string(builder)
}