1// Copyright (c) 2011 CZ.NIC z.s.p.o. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5// blame: jnml, labs.nic.cz
6
7// +build ignore
8
9package main
10
11import (
12	"bufio"
13	"flag"
14	"github.com/cznic/mathutil"
15	"log"
16	"math"
17	"os"
18)
19
20/*
21
22$ # Usage e.g.:
23$ go run example.go -max 1024 > mathutil.dat # generate 1kB of "random" data
24
25*/
26func main() {
27	r, err := mathutil.NewFC32(math.MinInt32, math.MaxInt32, true)
28	if err != nil {
29		log.Fatal(err)
30	}
31
32	var mflag uint64
33	flag.Uint64Var(&mflag, "max", 0, "limit output to max bytes")
34	flag.Parse()
35	stdout := bufio.NewWriter(os.Stdout)
36	if mflag != 0 {
37		for i := uint64(0); i < mflag; i++ {
38			if err := stdout.WriteByte(byte(r.Next())); err != nil {
39				log.Fatal(err)
40			}
41		}
42		stdout.Flush()
43		return
44	}
45
46	for stdout.WriteByte(byte(r.Next())) == nil {
47	}
48}
49