Closed howardjohn closed 3 years ago
You can use goda graph "reach(., c:root)"
to get the necessary graph.
Also there's goda help expr
that prints the help about the expressions.
Also sometimes using goda graph "transitive(reach(., c:root))"
can be a nicer graph to work with.
Ah fantastic, I only tried goda tree
and goda list
with reach
which is why I had problems since it doesn't have an expr. This works great!
Is there any reason tree
doesn't support expr
? If its just not enough time to implement it I may be interested in sending a PR if I find some time and you are interested - let me know. Otherwise, seems like this can be closed now. Thanks for the help + the great tool
Honestly, I don't see a reason why it couldn't support it.
And, if you want to take a stab at it, then great.
Basically, you need to replace https://github.com/loov/goda/blob/master/tree/cmd.go#L48 with code https://github.com/loov/goda/blob/master/graph/cmd.go#L75 and then adjust the printing to work with the result.
I have very often wanted to run a command to see why a dependency is required. This could be similar to
go mod why
, although that command is lacking a bit of functionality.Essentially, given an import tree of
I would like a command like:
goda why . c
I would expect:From this, I can see all of the places I need to clean up usages of
c
if I want to drop the dependency.I have done this exact thing before using a bunch of ad-hoc
goda
commands, resulting in out binary sizes being cut in half, so I think it would be pretty useful. It feels like all of the information is there, but not presentable in this way. Its also possible I just haven't found the right expressions to represent this.Alternatives:
Here the tree is pretty much the same, but in our real repo the tree is 12k lines so its not usable for this use case. The same with the graph - its too big to read without filtering