There's currently a bug which will print additional lines, since append adds to
the end of an array instead of starting from the first open position. That cause
strings.Join to print empty lines for each of the pre-allocated array elements.
So, this CL changes the make to set capacity instead of len, and sets len to 0.
Change-Id: Iaf6d07ca2648d0bbcafcd21a5b485cccd7f0c68c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/208137
Run-TryBot: Jean de Klerk <deklerk@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Focus prints the subgraph of all paths through the focused label.
Change-Id: I20fa9fb079f733addcd3cec85aa608f4979fdb24
Reviewed-on: https://go-review.googlesource.com/c/tools/+/184357
Reviewed-by: Jay Conrod <jayconrod@google.com>
Currently, vertices are referred to as nodes in (most) user-facing
documentation, and labels in the code itself (and some user-facing
documentation). This CL changes all references to vertices to use the word node.
Change-Id: I0a409c08122f198b11ff891cbea24b41aba89e40
Reviewed-on: https://go-review.googlesource.com/c/tools/+/200938
Reviewed-by: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
Refactors somepath to print an adjacency list from "from" to "to", instead of
just the nodes. This allows other tools like modgraphviz to print the subgraph.
This is a breaking change. The previous behavior returned vertices; now it
returns edges. If you relied on the previous behavior, use:
my-application | digraph somepath <from> <to> | digraph nodes
Change-Id: Id5e77e19eea79849ec6f25018f627c8dc4e2a831
Reviewed-on: https://go-review.googlesource.com/c/tools/+/184338
Run-TryBot: Alan Donovan <adonovan@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
Refactors allpaths to print an adjacency list from "from" to "to", instead of
just the nodes. This allows other tools like modgraphviz to print the subgraph.
For example, the following command:
cd $GOPATH/src/cloud.google.com/go && \
go mod graph | \
digraph allpaths cloud.google.com/go golang.org/x/text@v0.3.2 | \
modgraphviz | \
dot -Tpng -o graph.png
Generates the following graph.png: https://user-images.githubusercontent.com/3584893/60481727-df0a8680-9c4b-11e9-8df9-c581d599edd1.png
Also splits out the allpaths tests into their own test, and adds many test
cases.
This is a breaking change. The previous behavior returned vertices; now it
returns edges. If you relied on the previous behavior, use:
my-application | digraph allpaths <from> <to> | digraph nodes
Change-Id: I2eb7c377f5fe1e1e90c5b74eaa78d5211192bb2a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/184337
Reviewed-by: Alan Donovan <adonovan@google.com>
- Move verbose usage docs to godoc, replace usage with terse description of
usage and commands.
- Add copyrights.
- Update usage to more canonical function format instead of const format.
Change-Id: I30d072f391bbf9911798e90efb85cd5351d99205
Reviewed-on: https://go-review.googlesource.com/c/tools/+/184177
Run-TryBot: Alan Donovan <adonovan@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
Also switch usage printing to using stderr always, as is common for Go
tools.
Change-Id: I240da4344fe6b51a418c0d4b0b7d7e7d5614c1d7
Reviewed-on: https://go-review.googlesource.com/129776
Reviewed-by: Alan Donovan <adonovan@google.com>
Such messages are more informative when the error occurs deep within a script.
Also: add tool name to digraph's usage messages.
LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/173380043
Rewrite performed with this command:
sed -i '' 's_code.google.com/p/go\._golang.org/x/_g' \
$(grep -lr 'code.google.com/p/go.' *)
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/170920043
Example: show the transitive closure of imports of the digraph tool itself:
% go list -f '{{.ImportPath}}{{.Imports}}' ... | tr '[]' ' ' |
digraph forward code.google.com/p/go.tools/cmd/digraph
+ basic test.
LGTM=gri
R=gri, sameer
CC=golang-codereviews
https://golang.org/cl/161760043