mirror of
https://github.com/lus/pasty.git
synced 2023-08-10 21:13:09 +03:00
15 lines
291 B
Go
15 lines
291 B
Go
|
package randx
|
||
|
|
||
|
import (
|
||
|
"math/rand"
|
||
|
)
|
||
|
|
||
|
// String returns a random string with the given length
|
||
|
func String(characters string, length int) string {
|
||
|
bytes := make([]byte, length)
|
||
|
for i := range bytes {
|
||
|
bytes[i] = characters[rand.Int63()%int64(len(characters))]
|
||
|
}
|
||
|
return string(bytes)
|
||
|
}
|