-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathsetup.go
More file actions
41 lines (34 loc) · 730 Bytes
/
setup.go
File metadata and controls
41 lines (34 loc) · 730 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//Copyright Farsight Security, Inc. 2017
/*
Command for building a bit-per-address file for IPv4.
Called with:
setup <filename>
Output files are 512MB in size.
*/
package main
import (
"log"
"os"
)
const addresses = 4294967295
const bytes = addresses / 8
// Generates a data-file given a filename
func genFile(file string) {
f, err := os.Create(file)
defer f.Close()
if err != nil {
log.Fatal(err)
}
if err := f.Truncate(bytes); err != nil {
log.Fatal(err)
}
}
func main() {
log.SetFlags(0) // turn off timestamps
if len(os.Args) < 2 {
log.Fatal("Usage\n\n setup <filename> - Generate a blank data file")
}
log.Println("Generating empty file: ", os.Args[1])
filename := os.Args[1]
genFile(filename)
}