From 9fc80a1f8abcdb43366945f597d0b191738efb2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Wed, 20 Nov 2019 12:18:50 +0100 Subject: [PATCH] Fix crash with empty table --- utils/table_printer.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/utils/table_printer.go b/utils/table_printer.go index fd38a928e..fa66b5ee4 100644 --- a/utils/table_printer.go +++ b/utils/table_printer.go @@ -22,7 +22,7 @@ func NewTablePrinter(w io.Writer) *TTYTablePrinter { out: w, IsTTY: tty, maxWidth: ttyWidth, - colWidths: []int{}, + colWidths: make(map[int]int), colFuncs: make(map[int]func(string) string), } } @@ -31,14 +31,11 @@ type TTYTablePrinter struct { out io.Writer IsTTY bool maxWidth int - colWidths []int + colWidths map[int]int colFuncs map[int]func(string) string } func (t *TTYTablePrinter) SetContentWidth(col, width int) { - if col == len(t.colWidths) { - t.colWidths = append(t.colWidths, 0) - } if width > t.colWidths[col] { t.colWidths[col] = width }