Paperclip/pkg/internal/services/random_id.go

16 lines
304 B
Go
Raw Permalink Normal View History

2024-08-18 06:09:52 +00:00
package services
import (
"math/rand"
)
2024-08-20 09:08:40 +00:00
var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
2024-08-18 06:09:52 +00:00
func RandString(length int) string {
builder := make([]rune, length)
for i := range builder {
builder[i] = letters[rand.Intn(len(letters))]
2024-08-18 06:09:52 +00:00
}
return string(builder)
2024-08-18 06:09:52 +00:00
}