Closed suntong closed 7 years ago
Main package is required for the analysis used, because all the calls in the callgraph tree begins in main (and inits).
In package you don't really know what will be called, since it's just a package without some start point. Program that will use the package can call anything or nothing.
Ok. Thanks.
Reopening the issue as I'm still unable to visualize call graph for Go libs, despite I've given it some start point:
go-callvis -group pkg,type -limit github.com/knq/xo github.com/knq/xo/examples/sqlite3 | dot -Tpng -o /tmp/out.png
and the result looks like this:
http://img.vim-cn.com/32/9823a165bf43ec1ce6fa5cacfee09b663543fe.png
I.e., the visualization is only limited within the "examples/sqlite3", but not down to the xo lib level, which is what I had hoped for, when using the -limit github.com/knq/xo
parameter.
As a comparison, here is what the level of details of xo lib call graph I'm hoping to see -- http://img.vim-cn.com/a3/c9865f9ef44f1994b760bb3c5c058c37838df0.png
So it is possible then? Thanks.
By default the -focus
flag is set to main so it only shows calls from and to that package.
You can use an empty string (-focus=""
) to show all the calls for the program. Although I warn you that it might generate huge output if you don't use -limit
or -nostd
.
Thanks a lot for your answer.
So I tried it:
go-callvis -group pkg,type -focus="" -limit github.com/knq/xo github.com/knq/xo/examples/sqlite3 | dot -Tpng -o /tmp/out.png
however, the result is almost like what I posted before:
http://img.vim-cn.com/70/d93fee55166de1f43504fd87e901b79c4fa7f7.png
Do you have a full command like above that I can try out myself please? It'd be great if you have and can try with any of the following packages:
github.com/andybalholm/cascadia/ github.com/beevik/etree/ github.com/deckarep/golang-set/ github.com/fatih/camelcase/ github.com/gnewton/chidley/ github.com/goji/ github.com/moovweb/gokogiri/ github.com/spf13/cobra/ github.com/zenazn/goji/
Or any smaller but useful packages that you have locally.
Thanks
I have tried project cobra's program github.com/spf13/cobra/cobra using:
go-callvis -group pkg -focus="" -limit github.com/spf13/cobra github.com/spf13/cobra/cobra | dot -Tpng -o cobra.png
Output: Are you looking for something like this?
I don't really know what happens inside github.com/knq/xo/examples/sqlite3
since it's not published, but could it be that the output you got from go-callvis has the only calls that happen for that example (for github.com/knq/xo path prefix)?
By the way, what did you use to generate the graph you sent before? http://img.vim-cn.com/a3/c9865f9ef44f1994b760bb3c5c058c37838df0.png
Thanks a lot for your answer. I tried a lot of other packages afterwards, all worked fine. Then I suddenly realized that the ko package I was initially investigating was a generated code. :-( the worst one to pick. :-(
So, all good now. Thanks again for your help.
BTW, the graph I sent before, http://img.vim-cn.com/a3/c9865f9ef44f1994b760bb3c5c058c37838df0.png, was generated using go's native callgraph
command, before I knew of go-callvis. There were much tedious manual cleanup afterward, that's why I'm interested in the automatically way provided by go-callvis. Thanks again for providing that.
Can
go-callvis
be used to visualize call graph for Go libs? I gotgo-callvis: no main packages
by doing so, and no output generated.Here are details: