import "math/rand"
func Read(p []byte) (n int, err error)
Read generates len(p) random bytes from the default Source and writes
them into p. It always returns len(p) and a nil error.func (r *Rand) Read(p []byte) (n int, err error)
Read generates len(p) random bytes and writes them into p. It always
returns len(p) and a nil error.
For example,
package main
import (
"math/rand"
"fmt"
)
func main() {
token := make([]byte, 4)
rand.Read(token)
fmt.Println(token)
}
Output:
[187 163 35 30]