Simple Golang Function For Generating Random String, Strong Password, OTP, Random ID / code for a Given Length
We all need to generate random strings, random strong password, One time password (OTP), Pass Code, Random user ID, Order Code, Invoice Code etc. So here I have an example go implementation for generating random string for a specific size in length and using it for different purposes.
Generating Random String in GoLang
- Take a charset as input
- Generating a random number within the length of the charset
- Use the random number as an index of the string and take the character to build up the random code
Output of for the example implementation
My One time password: LY4V-PMGS My random strong password: [email protected]