loov / goda

Go Dependency Analysis toolkit
MIT License
1.37k stars 45 forks source link

graph: collapsing modules, internal and arbitrary keywords #41

Open egonelbre opened 3 years ago

egonelbre commented 3 years ago

During output it would be nice to collapse some particular nodes into a single node.

For example, these could be collapsed:

  1. modules
  2. */internal/*
  3. golang.org/x/tools/*
  4. everything except the project module (or multiple modules)

This sounds like pkggraph needs collapsing and uncollapsing capabilities so that the code can be written as:

goda graph -m .
goda graph -collapse "*/internal/*" .
goda graph -collapse "golang.org/x/tools/*" .

# combining all together
goda graph -m -uncollapse github.com/loov/goda -collapse "*/internal/*" .
dolmen commented 3 years ago

I have an independent experimental project (not yet published on GitHub: I need a name) that makes a graph packages, using modules as clusters. I think that hiding packages internal to a module (packages which do not link to packages from other modules, besides stdlib) is helpful to make the graph more readable.

iskunk commented 2 years ago

For what it's worth, point 1 alone would be enough for my usage. I am using the output of goda with an application that normally parses the output of go list -m all and go mod graph, and nodes that are not present in the former listing are unrecognized. (This is in tandem with a third-party database that uses the module paths as keys, so I can't just replace the go list output with goda's.)