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

README to explain `<target package>` #182

Open AndrewWPhillips opened 2 months ago

AndrewWPhillips commented 2 months ago

Seems like a great tool but the "quick start" in the README needs some work. It's not explained well esp. what is <target package>. It's also not very clear how it works with (just uses Go source files I think) and that it runs a webserver to serve the results (by default). (This was on Windows but I'll also try Linux when I get my Ubuntu laptop working.)

I also googled and checked the Github issues but still could not get it to work.

I tried various things with these errors (cmd shell and git-bash):

go-callvis main # -: package main is not in std (D:\Golang\go1.21.6\src\main)

$ go-callvis main # -: package main is not in GOROOT (C:\Program Files\Go\src\main)

$ go-callvis main.go # C:\Program Files\Go\src\internal\abi\abi.go:117:19: undeclared name: any + 100s more errors

$ go-callvis github.com//test # using the module name (go.mod) got same (above) error

$ go-callvis github.com//test/main # -: no required module provides package github.com//test/main

$ go-callvis test.exe # -: no required module provides package test.exe

There were also other suggestions in other issues for the README. (I'd be happy to update the README once I work out how to use it :)

AndrewWPhillips commented 2 months ago

I got it to work with go 1.18. Then working backwards now have it working with 1.21.6. Long story but when running in git-bash it is picking up the std library files from C:\Program Files\Go\src\ (which has 1.18 source code) due to GOROOT.

In summary, I believe <target package> is not the package but the module name, or (if there is only one .go file in the package) the name of the .go file.