-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
50 lines (42 loc) · 999 Bytes
/
main.go
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
42
43
44
45
46
47
48
49
50
package main
import (
"fmt"
_ "net/http/pprof"
"os"
"sync"
"time"
)
var errors uint64
func main() {
var progname string = os.Args[0]
var input []string = os.Args[1:]
flags, usage := parseFlags(progname, input, &config)
if flags.version {
stop(version, 0)
}
config = *loadConfig(flags.config)
args = *parseArgs(progname, input, &config)
if args.target == "" {
usage()
os.Exit(0)
}
t := time.Now()
target := loadTarget()
run(target)
disconnect()
if !args.quiet {
fmt.Printf("%s: %d seconds elapsed\n", args.target, int(time.Since(t).Seconds()))
}
}
func run(target *Target) {
var wg sync.WaitGroup
wg.Add(1)
go func(target *Target) {
extractChannel := make(chan []map[string]interface{}, args.page*args.workers*10)
transformChannel := make(chan []map[string]interface{}, args.page*args.workers*10)
go extract(target, extractChannel)
go transform(target, extractChannel, transformChannel)
go write(target, transformChannel, &wg)
}(target)
wg.Wait()
}