Generating random numbers
Random number generation is an art as well as a research area in computer science. This is because computers are purely logical machines, and it turns out that using them to generate random numbers is extremely difficult!
Go can help you with that using the functionality of the math/rand
package. Each random number generator needs a seed to start producing numbers. The seed is used for initializing the entire process and is extremely important because if you always start with the same seed, you will always get the same sequence of pseudo-random numbers. This means that everybody can regenerate that sequence, and that particular sequence will not be random after all.
However, this feature is very handy for testing purposes. In Go, the rand.Seed()
function is used for initializing a random number generator.
If you are really interested in random number generation, you should start by reading the second volume of The Art of Computer Programming...