Skip to content

Instantly share code, notes, and snippets.

@lowlevel-1989
Created February 2, 2018 03:26
Show Gist options
  • Save lowlevel-1989/23c3ff9b2b005906b84daebf3e0e586a to your computer and use it in GitHub Desktop.
Save lowlevel-1989/23c3ff9b2b005906b84daebf3e0e586a to your computer and use it in GitHub Desktop.
golang rand binary
package main
import (
"crypto/rand"
"io"
"bytes"
"bufio"
"fmt"
)
func main() {
var b bytes.Buffer
size := 5
out := bufio.NewWriterSize(&b, size)
in := rand.Reader
_, _ = io.CopyN(out, in, int64(size))
fmt.Printf("%v", b.Bytes()[:size])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment