This is my version of the random password generator i wrote in C++.
package main
import (
"fmt"
"math/rand"
"os"
"strconv"
"time"
)
func main() {
var length int
if len(os.Args) != 2 {
length = 8
} else {
length, _ = strconv.Atoi(os.Args[1])
}
chars := ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()`~-_=+[{]{\\|;:'\",<.>/? ")
rnd := rand.New(rand.NewSource(time.Now().UTC().UnixNano()))//entropy
lenChars := len(chars)
password := make([]byte, length)
for i := 0; i < length; i++ {
password[i] = chars[rnd.Intn(lenChars)]
}
fmt.Println(string(password))
}