This section will illustrate how to create good random passwords in Go, in order to protect the security of your Unix machines. The main reason for including it here instead of another chapter is because the presented Go program will use the /dev/random device, which is a file defined by your Unix system, for getting the seed of the random number generator.
The name of the Go program will be goodPass.go, and it will require just one optional parameter, which will be the length of the generated password: the default size of the generated password will be 10 characters. Additionally, the program will generate ASCII characters starting from ! up to z. The ASCII code of the exclamation mark is 33, whereas the ASCII code of small z is 122.
The first part of goodPass.go is the required preamble:
package main import ( "encoding/binary"...