1
0
mirror of https://github.com/golang/go synced 2024-11-18 13:44:48 -07:00
go/cmd/callgraph
Dmitri Shuralyov 5831d16d18 cmd/callgraph: fix "import path of the enclosing package" example in usage
Caller is *ssa.Function. Its Pkg field is *ssa.Package. But ssa.Package
struct doesn't contain either field or method named Object.

So one gets the following error:

	$ callgraph -format '{{.Caller.Pkg.Object.Path}} -> {{.Callee.Pkg.Object.Path}}' \
	    $(go env GOROOT)/src/net/http/triv.go | sort | uniq
	callgraph: template: -format:1:9: executing "-format" at <.Caller.Pkg.Object.P...>: can't evaluate field Object in type *ssa.Package

ssa.Package contains Pkg field:

	Pkg     *types.Package    // the corresponding go/types.Package

types.Package contains Path() method that returns the package path.

That appears to be the right way to get the "import path of the
enclosing package" with the current x/tools/go/ssa API.

Fixes golang/go#20459.

Change-Id: I3cb7b61b767148f5c771d57f8f5e7e6ab20aea87
Reviewed-on: https://go-review.googlesource.com/43812
Reviewed-by: Avelino <t@avelino.xxx>
Reviewed-by: Alan Donovan <adonovan@google.com>
2017-08-08 14:46:45 +00:00
..
testdata/src/pkg cmd/callgraph: a utility for dumping the callgraph of a Go program. 2014-11-12 17:36:22 -05:00
main_test.go go/ssa: support custom TestMain functions in test packages 2016-10-19 17:50:59 +00:00
main.go cmd/callgraph: fix "import path of the enclosing package" example in usage 2017-08-08 14:46:45 +00:00