Created
May 28, 2017 02:36
-
-
Save DavadDi/8944292b59d7e74812cb91788218a246 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
var ( | |
codes = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/~!@#$%^&*()_=" | |
codeLen = len(codes) | |
) | |
func RandNewStr(len int) string { | |
data := make([]byte, len) | |
rand.Seed(time.Now().UnixNano()) | |
for i := 0; i < len; i++ { | |
idx := rand.Intn(codeLen) | |
data[i] = byte(codes[idx]) | |
} | |
return string(data) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment