The math and rand packages do not provide the same amount of randomness that the crypto/rand package offers. Do not use math/rand for cryptographic applications.
The following example will demonstrate how to generate random bytes, a random integer, or any other signed or unsigned type of integer:
package mainimport ( "crypto/rand" "encoding/binary" "fmt" "log" "math" "math/big")func main() { // Generate a random int limit := int64(math.MaxInt64) // Highest random number allowed randInt, err := rand.Int(rand.Reader, big.NewInt(limit)) if err != nil { log.Fatal(err) } fmt.Println("Random int value: ...