1
0
mirror of https://github.com/golang/go synced 2024-11-18 09:04:49 -07:00

cmd/digraph: omit unnecessary empty lines in focus

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>
This commit is contained in:
Jean de Klerk 2019-11-20 08:44:25 -07:00
parent e97fc27222
commit b3340bdf36

View File

@ -526,7 +526,7 @@ func digraph(cmd string, args []string) error {
}
}
edgesSorted := make([]string, len(edges))
edgesSorted := make([]string, 0, len(edges))
for e := range edges {
edgesSorted = append(edgesSorted, e)
}