go-urlsh/internal/misc/misc.go

16 lines
243 B
Go
Raw Normal View History

2023-04-25 18:43:01 +02:00
package misc
import (
"math/rand"
)
func RandomString(n int) string {
var letters = []rune("abcdefghijklmnopqrstuvwxyz0123456789")
s := make([]rune, n)
for i := range s {
s[i] = letters[rand.Intn(len(letters))]
}
return string(s)
}