-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
53 lines (44 loc) · 759 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
51
52
53
package main
import (
"bufio"
"fmt"
"os"
// "github.com/pkg/errors"
)
//log should be produced by "git log --no-merges --numstat --date=iso8601"
func main() {
writer := NewCommitDBWriter()
err := writer.Init()
if err != nil {
fmt.Printf("%+v\n", err)
os.Exit(1)
}
defer writer.Close()
f, err := os.Open("big.log")
if err != nil {
panic(err)
}
defer func() {
if err = f.Close(); err != nil {
panic(err)
}
}()
s := bufio.NewScanner(f)
reader := NewLogReader(writer.Consume)
for s.Scan() {
err = reader.ReadLine(s.Text())
if err != nil {
fmt.Printf("%+v\n", err)
os.Exit(1)
}
}
err = reader.close()
if err != nil {
fmt.Printf("%+v\n", err)
os.Exit(1)
}
err = s.Err()
if err != nil {
panic(err)
}
}