Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions output.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,22 @@ import (
"strings"

"golang.org/x/tools/go/callgraph"
"golang.org/x/tools/go/packages"
"golang.org/x/tools/go/ssa"
)

var stdPackages = map[string]struct{}{}

func init() {
pkgs, err := packages.Load(nil, "std")
if err != nil {
panic(err)
}
for _, p := range pkgs {
stdPackages[p.PkgPath] = struct{}{}
}
}

func isSynthetic(edge *callgraph.Edge) bool {
// TODO: consider handling callee.Func.Pkg == nil
// this could still generate a node for the call, might be useful
Expand All @@ -25,10 +38,8 @@ func inStd(node *callgraph.Node) bool {
}

func isStdPkgPath(path string) bool {
if strings.Contains(path, ".") {
return false
}
return true
_, ok := stdPackages[path]
return ok
}

func printOutput(
Expand Down
Loading