-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
49 lines (41 loc) · 878 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
package main
import (
"flag"
"fmt"
"sort"
)
var path string
var buildFlag string
func main() {
flag.StringVar(&path, "path", ".", "package path")
flag.StringVar(&buildFlag, "buildflag", "--tags=", "build flag")
flag.Parse()
cg, prog, err := doCallgraph("vta", false, getAllPackageName(path))
if err != nil {
panic(err)
}
analyzer1 := NewVarAnalyzer(path, cg, prog)
analyzer1.Analysis()
analyzer2 := NewStructFieldAnalyzer(path, cg, prog)
analyzer2.Analysis()
m := map[string]bool{}
s := append(analyzer1.PrintsCall, analyzer2.PrintsCall...)
sort.Sort(s)
for _, v := range s {
if _, ok := m[v]; ok {
continue
}
m[v] = true
fmt.Println(v)
}
m = map[string]bool{}
s = append(analyzer1.PrintsReturn, analyzer2.PrintsReturn...)
sort.Sort(s)
for _, v := range s {
if _, ok := m[v]; ok {
continue
}
m[v] = true
fmt.Println(v)
}
}