-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
64 lines (55 loc) · 1.08 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
61
62
63
64
package main
import (
"./globbing"
"./metrics"
"encoding/json"
"fmt"
"net/url"
"os"
)
func main() {
address := os.Args[1:][0]
project, err := url.QueryUnescape(address)
files, err := globbing.GetFiles(project)
if err != nil {
fmt.Println(err)
}
result, str := metrics.Count(files)
data, err := json.MarshalIndent(result, "", " ")
///metricsAnalyzer/result.json
resultDir := project + "/metricsAnalyzer"
_ = os.Mkdir(resultDir, 0755)
f, err := os.Create(resultDir + "/result.json")
if err != nil {
//panic(err)
fmt.Println(err)
}
_, err = f.Write(data)
if err != nil {
fmt.Println(err)
//panic(err)
}
f.Close()
f, err = os.Create(resultDir + "/result.txt")
_, err = f.Write([]byte(str))
if err != nil {
fmt.Println(err)
//panic(err)
}
f.Close()
//defer time.Sleep(10 * time.Second)
}
/*
func display(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/html")
t, err := template.ParseFiles("layout.html")
if err != nil {
panic(err)
}
err = t.Execute(w, nil)
if err != nil {
panic(err)
}
//fmt.Fprintf(w, "fvfv %v", 0)
}
*/