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

what dose these mean in the svg file? "$" "#" #35

Closed yj511608130 closed 5 years ago

yj511608130 commented 5 years ago

i am a new comer to this nice project , and i begin to use go-callvis to analyze the source code of golevedbhttps://github.com/syndtr/goleveldb.after i generate the svg file , i find some symbols(eg. "$","#" in "main$6", "main$5$1$1" ,"init#1" free-converter com-111-92282555

) in the svg. what does these symbols mean? Do they mean a goroutine function call? my commond is blow: go-callvis -group pkg,type -nostd -nodesep 0.05 -limit github.com/syndtr github.com/syndtr/goleveldb/manualtest/dbstress

yj511608130 commented 5 years ago

ok,I know! that represents anonymous functions in golang

Russtopia commented 5 years ago

I've submitted an enhancement request to allow naming anonymous goroutines in the diagram.. perhaps I can figure out how to implement that myself and submit a pull request. Of course it would be even nicer if Go v2 allowed named goroutines :)

ondrajz commented 5 years ago

It seems you figured it out. For anyone else who might stumble upon this, here's list of possible function names:

"math.IsNaN"                  // a package-level function
"(*bytes.Buffer).Bytes"       // a declared method or a wrapper
"(*bytes.Buffer).Bytes$thunk" // thunk (func wrapping method; receiver is param 0)
"(*bytes.Buffer).Bytes$bound" // bound (func wrapping method; receiver supplied by closure)
"main.main$1"                 // an anonymous function in main
"main.init#1"                 // a declared init function
"main.init"                   // the synthesized package initializer

more at: golang.org/x/tools/go/ssa#Function.RelString