-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.go
60 lines (54 loc) · 1.16 KB
/
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
51
52
53
54
55
56
57
58
59
60
/*
* Author Linvon
*/
package main
import (
"fmt"
"log"
"os"
"strconv"
"time"
)
func main() {
fileList := parseArgs()
t := time.Now()
initData()
for _, v := range fileList {
s := time.Now()
file, isGz, err := getFile(v)
if err != nil {
fmt.Printf("cannot able to read the file %v, err %v\n", v, err)
continue
}
err = process(file, isGz)
if err != nil {
fmt.Printf("handle filr %v err %v\n", v, err)
}
_ = file.Close()
fmt.Printf("File %v Time taken - %v\n", v, time.Since(s))
}
fmt.Printf("All Time taken - %v\n", time.Since(t))
outPut()
}
// TODO Customize your log file format : xlog-2020-07-27_00001(.gz)
func parseArgs() []string {
args := os.Args[1:]
if len(args) != 3 {
log.Fatalln("Format ./coreader 200727 0 190(date start end)")
}
format := args[0]
start, err := strconv.Atoi(args[1])
if err != nil {
log.Fatalln("Format ./coreader 200727 0 190(date start end)")
}
end, err := strconv.Atoi(args[2])
if err != nil {
log.Fatalln("Format ./coreader 200727 0 190(date start end)")
}
fList := make([]string, 0)
for i := start; i < end; i++ {
s := fmt.Sprintf(format, i)
fList = append(fList, s)
}
return fList
}