You've already forked golang-base-project
Improves documentation (#13)
* Documents all env variables and adds an example project * Adds godoc comments * Fixed package naming issue
This commit is contained in:
15
text/random.go
Normal file
15
text/random.go
Normal file
@ -0,0 +1,15 @@
|
||||
package text
|
||||
|
||||
import "math/rand"
|
||||
|
||||
// RandomString generates a random string of n length. Based on https://stackoverflow.com/a/22892986/1260548
|
||||
func RandomString(n int) string {
|
||||
// remove vowels to make it less likely to generate something offensive
|
||||
var letters = []rune("bcdfghjklmnpqrstvwxzBCDFGHJKLMNPQRSTVWXZ")
|
||||
|
||||
b := make([]rune, n)
|
||||
for i := range b {
|
||||
b[i] = letters[rand.Intn(len(letters))]
|
||||
}
|
||||
return string(b)
|
||||
}
|
Reference in New Issue
Block a user