Created
October 23, 2018 16:40
-
-
Save traetox/d6be0f1bd7ed71927b658419f22c939d to your computer and use it in GitHub Desktop.
generate brutally incoherent timestamped line data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"flag" | |
"math/rand" | |
"time" | |
"log" | |
"os" | |
) | |
const ( | |
mil int64 = 1000000 | |
) | |
var ( | |
fcnt = flag.Int("c", 1000, "Line count") | |
fpath = flag.String("o", "", "output file path") | |
) | |
func init() { | |
flag.Parse() | |
if *fcnt <= 0 { | |
log.Fatal("invalid count") | |
} | |
if *fpath == `` { | |
log.Fatal("Invalid path") | |
} | |
rand.Seed(time.Now().UnixNano()) | |
} | |
func main() { | |
fout, err := os.Create(*fpath) | |
if err != nil { | |
log.Fatal(err) | |
} | |
var offset int | |
var n int | |
for i := 0; i < *fcnt; i++ { | |
b := make([]byte, rand.Intn(1024)) | |
rand.Read(b) | |
fmt.Printf("%x\n", offset) | |
n, _ = fmt.Fprintf(fout, "%d,", time.Now().UnixNano()/mil) | |
offset += n | |
n, _ = fout.Write(b) | |
offset += n | |
n, _ = fmt.Fprintf(fout, "\n") | |
offset += n | |
} | |
if err = fout.Close(); err != nil { | |
log.Fatal(err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment