Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/cmd/callgraph: usage text suggests invalid code #20459

Closed
dmitshur opened this issue May 22, 2017 · 1 comment
Closed

x/tools/cmd/callgraph: usage text suggests invalid code #20459

dmitshur opened this issue May 22, 2017 · 1 comment

Comments

@dmitshur
Copy link
Contributor

dmitshur commented May 22, 2017

The usage text of x/tools/cmd/callgraph command mentions:

e.g. Caller.Pkg.Object.Path yields the import path of the enclosing package.
Consult the go/ssa API documentation for details.

Examples:

callgraph -format '{{.Caller.Pkg.Object.Path}} -> {{.Callee.Pkg.Object.Path}}' \
  $GOROOT/src/net/http/triv.go | sort | uniq

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

I'm guessing that instead of Caller.Pkg.Object.Path, it should be Caller.Pkg.Pkg.Path:

https://godoc.org/golang.org/x/tools/go/ssa#Package.Pkg

That works as expected in my testing.

My environment details:

What version of Go are you using (go version)?

$ go version
go version go1.8.1 darwin/amd64

What operating system and processor architecture are you using (go env)?

$ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/Dmitri/Dropbox/Work/2013/GoLanding:/Users/Dmitri/Dropbox/Work/2013/GoLand"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/tw/kgz4v2kn4n7d7ryg5k_z3dk40000gn/T/go-build822597389=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2" 
@gopherbot gopherbot added this to the Unreleased milestone May 22, 2017
@gopherbot
Copy link

CL https://golang.org/cl/43812 mentions this issue.

@golang golang locked and limited conversation to collaborators Aug 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants