File tree 1 file changed +15
-4
lines changed
1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -9,9 +9,22 @@ import (
9
9
"strings"
10
10
11
11
"golang.org/x/tools/go/callgraph"
12
+ "golang.org/x/tools/go/packages"
12
13
"golang.org/x/tools/go/ssa"
13
14
)
14
15
16
+ var stdPackages = map [string ]struct {}{}
17
+
18
+ func init () {
19
+ pkgs , err := packages .Load (nil , "std" )
20
+ if err != nil {
21
+ panic (err )
22
+ }
23
+ for _ , p := range pkgs {
24
+ stdPackages [p .PkgPath ] = struct {}{}
25
+ }
26
+ }
27
+
15
28
func isSynthetic (edge * callgraph.Edge ) bool {
16
29
// TODO: consider handling callee.Func.Pkg == nil
17
30
// this could still generate a node for the call, might be useful
@@ -25,10 +38,8 @@ func inStd(node *callgraph.Node) bool {
25
38
}
26
39
27
40
func isStdPkgPath (path string ) bool {
28
- if strings .Contains (path , "." ) {
29
- return false
30
- }
31
- return true
41
+ _ , ok := stdPackages [path ]
42
+ return ok
32
43
}
33
44
34
45
func printOutput (
You can’t perform that action at this time.
0 commit comments