ondrajz / go-callvis

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

Generate call graph for packages that depends on Go 1.16 #99

Closed suntong closed 2 years ago

suntong commented 2 years ago

Hi,

This is what I got:

$ go-callvis -ignore embed,io/fs .
templates/templates.go:6:2: cannot find package "embed" in any of:
        /usr/lib/go-1.15/src/embed (from $GOROOT)
        /path/to/Go/src/embed (from $GOPATH)
templates/templates.go:8:2: cannot find package "io/fs" in any of:
        /usr/lib/go-1.15/src/io/fs (from $GOROOT)
        /path/to/Go/src/io/fs (from $GOPATH)
/path/to/Go/src/github.com/xo/xo/templates/templates.go:6:2: could not import embed (invalid package name: "")
/path/to/Go/src/github.com/xo/xo/templates/templates.go:8:2: could not import io/fs (invalid package name: "")
/path/to/Go/src/github.com/xo/xo/cmd/cmd.go:231:53: DirFS not declared by package os
. . .

I've already use -ignore embed,io/fs to tell go-callvis to ignore embed,io/fs, but why it is still trying to work on it?

Internally, how does thing work? E.g, if I got one go-callvis compiled with go-1.16, would it understand packages that depends on Go 1.16, while my go is still 1.15?

thanks

ondrajz commented 2 years ago

The call graph analysis happens for the source code and since it uses some internal Go libraries it will use the ones installed to resolve the call graph. The project you ran it for requires go 1.16 so to build the call graph you will need go 1.16 too.

suntong commented 2 years ago

OK, Thanks. So

right?

ondrajz commented 2 years ago

Yes, that is correct. Try it and let me know if you are still having issues.

suntong commented 2 years ago

Thanks! will do.