ondrajz / go-callvis

Visualize call graph of a Go program using Graphviz
https://ofabry.github.io/go-callvis
MIT License
5.91k stars 408 forks source link

[Question] can't generate the call graph for hashicorp/raft #15

Closed smallnest closed 6 years ago

smallnest commented 6 years ago

I use the below command"

go-callvis -focus github.com/hashicorp/raft github.com/hashicorp/raft -limit github.com/hashicorp/raft -nostd

but there are many errors:

/Users/yuepan/go/src/github.com/hashicorp/raft/util.go:58:15: undeclared name: crand
/Users/yuepan/go/src/github.com/hashicorp/raft/util.go:59:9: undeclared name: fmt
/Users/yuepan/go/src/github.com/hashicorp/raft/util.go:62:9: undeclared name: fmt
/Users/yuepan/go/src/github.com/hashicorp/raft/util.go:129:9: undeclared name: fmt
/Users/yuepan/go/src/github.com/hashicorp/raft/util.go:132:9: invalid operation: buf (variable of type *invalid type) has no field or method Bytes
/Users/yuepan/go/src/github.com/hashicorp/raft/util.go:140:9: undeclared name: fmt
/Users/yuepan/go/src/github.com/hashicorp/raft/util.go:154:7: undeclared name: bytes
/Users/yuepan/go/src/github.com/hashicorp/raft/util.go:162:9: undeclared name: bytes
cannot find package "-limit" in any of:
    /usr/local/Cellar/go/1.7.4/libexec/src/-limit (from $GOROOT)
    /Users/yuepan/go/src/-limit (from $GOPATH)
cannot find package "-nostd" in any of:

Maybe I have made a mistake to use it.

My question is how to use it for github.com/hashicorp/raft github.com/hashicorp/raft

ondrajz commented 6 years ago

Try putting the target package argument github.com/hashicorp/raft after all the flags, like this:

go-callvis -focus github.com/hashicorp/raft -limit github.com/hashicorp/raft -nostd github.com/hashicorp/raft
smallnest commented 6 years ago

Thanks @TrueFurby , but it still has some errors:

go-callvis -focus github.com/hashicorp/raft -limit github.com/hashicorp/raft github.com/hashicorp/raft
.......
Users/yuepan/go/src/github.com/hashicorp/raft/util.go:23:47: undeclared name: math
/Users/yuepan/go/src/github.com/hashicorp/raft/util.go:25:9: undeclared name: fmt
/Users/yuepan/go/src/github.com/hashicorp/raft/util.go:35:12: undeclared name: time
/Users/yuepan/go/src/github.com/hashicorp/raft/util.go:35:26: undeclared name: rand
/Users/yuepan/go/src/github.com/hashicorp/raft/util.go:36:9: undeclared name: time
/Users/yuepan/go/src/github.com/hashicorp/raft/util.go:58:15: undeclared name: crand
/Users/yuepan/go/src/github.com/hashicorp/raft/util.go:59:9: undeclared name: fmt
/Users/yuepan/go/src/github.com/hashicorp/raft/util.go:62:9: undeclared name: fmt
/Users/yuepan/go/src/github.com/hashicorp/raft/util.go:129:9: undeclared name: fmt
/Users/yuepan/go/src/github.com/hashicorp/raft/util.go:132:9: invalid operation: buf (variable of type *invalid type) has no field or method Bytes
/Users/yuepan/go/src/github.com/hashicorp/raft/util.go:140:9: undeclared name: fmt
/Users/yuepan/go/src/github.com/hashicorp/raft/util.go:154:7: undeclared name: bytes
/Users/yuepan/go/src/github.com/hashicorp/raft/util.go:162:9: undeclared name: bytes
go-callvis: couldn't load packages due to errors: github.com/hashicorp/raft, github.com/hashicorp/go-msgpack/codec, github.com/armon/go-metrics and 2 more
ondrajz commented 6 years ago

This seems like issue with compiling the package github.com/hashicorp/raft itself.

Try running: go install github.com/hashicorp/raft

I tried downloading it and compiling with go 1.8.3 successfully. What Go version do you use?

smallnest commented 6 years ago

Go 1.9.

I have updated "raft" : go get -u github.com/hashicorp/raft

ondrajz commented 6 years ago

So, it works now?

smallnest commented 6 years ago

No, same problems to the above. It looks it can't find stdlib:

/Users/yuepan/go/src/github.com/hashicorp/go-msgpack/codec/binc.go:7:2: could not import math (cannot find package "math" in any of:
    /usr/local/Cellar/go/1.7.4/libexec/src/math (from $GOROOT)
    /Users/yuepan/go/src/math (from $GOPATH))
/Users/yuepan/go/src/github.com/hashicorp/go-msgpack/codec/binc.go:10:2: could not import time (cannot find package "time" in any of:
    /usr/local/Cellar/go/1.7.4/libexec/src/time (from $GOROOT)
    /Users/yuepan/go/src/time (from $GOPATH))
/Users/yuepan/go/src/github.com/hashicorp/go-msgpack/codec/decode.go:7:2: could not import io (cannot find package "io" in any of:
    /usr/local/Cellar/go/1.7.4/libexec/src/io (from $GOROOT)
    /Users/yuepan/go/src/io (from $GOPATH))
/Users/yuepan/go/src/github.com/hashicorp/go-msgpack/codec/decode.go:8:2: could not import reflect (cannot find package "reflect" in any of:
    /usr/local/Cellar/go/1.7.4/libexec/src/reflect (from $GOROOT)
    /Users/yuepan/go/src/reflect (from $GOPATH))
/Users/yuepan/go/src/github.com/hashicorp/go-msgpack/codec/encode.go:7:2: could not import io (cannot find package "io" in any of:
    /usr/local/Cellar/go/1.7.4/libexec/src/io (from $GOROOT)
    /Users/yuepan/go/src/io (from $GOPATH))
/Users/yuepan/go/src/github.com/hashicorp/go-msgpack/codec/encode.go:8:2: could not import reflect (cannot find package "reflect" in any of:
    /usr/local/Cellar/go/1.7.4/libexec/src/reflect (from $GOROOT)
smallnest commented 6 years ago

But I installed go1.9

smallnest commented 6 years ago
➜  raft git:(master) ✗ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/yuepan/go"
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/gq/jd9v5dd95p570hkztblb8ht40000gn/T/go-build725023326=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
ondrajz commented 6 years ago

You have GOROOT set to /usr/local/go, but for some reason during the compilation it seems to using /usr/local/Cellar/go/1.7.4/libexec/ to look for stdlib.

smallnest commented 6 years ago

It should be caused by this. I have ever installed go by brew but I have uninstalled it then. Now I install go manually. It is not an issue of go-callvis.

I will investigate how to fix it .

Thanks @TrueFurby

yanjinbin commented 2 years ago

I use the below command"

go-callvis -focus github.com/hashicorp/raft github.com/hashicorp/raft -limit github.com/hashicorp/raft -nostd

but there are many errors:

/Users/yuepan/go/src/github.com/hashicorp/raft/util.go:58:15: undeclared name: crand
/Users/yuepan/go/src/github.com/hashicorp/raft/util.go:59:9: undeclared name: fmt
/Users/yuepan/go/src/github.com/hashicorp/raft/util.go:62:9: undeclared name: fmt
/Users/yuepan/go/src/github.com/hashicorp/raft/util.go:129:9: undeclared name: fmt
/Users/yuepan/go/src/github.com/hashicorp/raft/util.go:132:9: invalid operation: buf (variable of type *invalid type) has no field or method Bytes
/Users/yuepan/go/src/github.com/hashicorp/raft/util.go:140:9: undeclared name: fmt
/Users/yuepan/go/src/github.com/hashicorp/raft/util.go:154:7: undeclared name: bytes
/Users/yuepan/go/src/github.com/hashicorp/raft/util.go:162:9: undeclared name: bytes
cannot find package "-limit" in any of:
  /usr/local/Cellar/go/1.7.4/libexec/src/-limit (from $GOROOT)
  /Users/yuepan/go/src/-limit (from $GOPATH)
cannot find package "-nostd" in any of:

Maybe I have made a mistake to use it.

My question is how to use it for github.com/hashicorp/raft github.com/hashicorp/raft

have you fix it ?