File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -9,9 +9,22 @@ import (
99 "strings"
1010
1111 "golang.org/x/tools/go/callgraph"
12+ "golang.org/x/tools/go/packages"
1213 "golang.org/x/tools/go/ssa"
1314)
1415
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+
1528func isSynthetic (edge * callgraph.Edge ) bool {
1629 // TODO: consider handling callee.Func.Pkg == nil
1730 // this could still generate a node for the call, might be useful
@@ -25,10 +38,8 @@ func inStd(node *callgraph.Node) bool {
2538}
2639
2740func isStdPkgPath (path string ) bool {
28- if strings .Contains (path , "." ) {
29- return false
30- }
31- return true
41+ _ , ok := stdPackages [path ]
42+ return ok
3243}
3344
3445func printOutput (
You can’t perform that action at this time.
0 commit comments