2021-06-29 17:52:43 +09:00
|
|
|
package testing
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"math/rand"
|
|
|
|
|
"time"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const letterBytes = "abcdefghijklmnopqrstuvwxyz"
|
|
|
|
|
|
2023-04-04 15:15:11 -04:00
|
|
|
var (
|
|
|
|
|
random = rand.New(rand.NewSource(time.Now().UnixNano()))
|
|
|
|
|
)
|
|
|
|
|
|
2021-06-29 17:52:43 +09:00
|
|
|
// Copied from https://stackoverflow.com/a/31832326 with thanks
|
|
|
|
|
func RandStringBytesRmndr(n int) string {
|
|
|
|
|
b := make([]byte, n)
|
|
|
|
|
for i := range b {
|
2023-04-04 15:15:11 -04:00
|
|
|
b[i] = letterBytes[random.Int63()%int64(len(letterBytes))]
|
2021-06-29 17:52:43 +09:00
|
|
|
}
|
|
|
|
|
return string(b)
|
|
|
|
|
}
|