Strings and Text
Examples
Filter
package main
import (
"fmt"
"math/rand"
"time"
)
var r = rand.New(rand.NewSource(time.Now().UnixNano()))
func RandomString(strlen int) string {
const chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
result := make([]byte, strlen)
for i := range result {
result[i] = chars[r.Intn(len(chars))]
}
return string(result)
}
func main() {
fmt.Println(RandomString(10))
}
Last Run
:
BFDoNyBToC