From b3340bdf36768190424880553cb76e063fb2890b Mon Sep 17 00:00:00 2001 From: Jean de Klerk Date: Wed, 20 Nov 2019 08:44:25 -0700 Subject: [PATCH] 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 Reviewed-by: Bryan C. Mills --- cmd/digraph/digraph.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/digraph/digraph.go b/cmd/digraph/digraph.go index 9d42b83c3d..ff2399fea0 100644 --- a/cmd/digraph/digraph.go +++ b/cmd/digraph/digraph.go @@ -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) }