-
-
Save diwakergupta/fa17945dd70c68938a5e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func GenerateRandomString(length int) string { | |
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz" | |
rand.Seed(time.Now().Unix()) | |
str := make([]string, length) | |
for i := 0; i < length; i++ { | |
index := rand.Intn(len(chars)) | |
str[i] = chars[index : index+1] | |
} | |
return strings.Join(str, "") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment