Here's a simple example in Go to generate a random password with uppercase and lowercase letters using the math/rand and crypto/rand packages:
main.go783 chars31 linesThis code generates a random password of length 12, using both uppercase and lowercase letters from the charset string. We first set the seed for the rand package using the current time in nanoseconds, to ensure we get a different sequence of random numbers each time we run the program. We then use a for loop to iterate over each character in the password and randomly select a character from the charset string using math/rand. Finally, we convert the byte array to a string and print the generated password.
gistlibby LogSnag