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

Calls between non-focused funcs are not shown #4

Closed ondrajz closed 7 years ago

ondrajz commented 7 years ago

Currently only calls to or from focused package are shown. However in cases when the results two contain functions which are both outside focused package and shown because focused package has some calls from/to both. Calls between such functions should be shown since both functions are already in the result anyway.

Example code

package main

import (
    "fmt"

    "golang.org/x/sync/errgroup"
)

func main() {
    var g errgroup.Group
    g.Go(func() error {
        fmt.Println("Hello world")
        return nil
    })
    g.Wait()
}

Result

result

You can see that main calls (*Group).Go and (*Group).Go$1 calls main$1. However the call between those two funcs inside errgroup is not shown even though both are in the result already.

By showing such calls the results would make clearer results by showing complete call path from the main to the fmt.Println.

Thanks @DmitriyMV for reporting this issue!

DmitriyMV commented 7 years ago

This is actually rather important, because there are libraries who are calling you back in the new goroutines. I'm looking forward to it 😃

ondrajz commented 7 years ago

Fixed in v0.3.4.

Output for the above code looks like this now: already