Skip to content

Commit 9fc80a1

Browse files
committed
Fix crash with empty table
1 parent 02b1f60 commit 9fc80a1

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

utils/table_printer.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func NewTablePrinter(w io.Writer) *TTYTablePrinter {
2222
out: w,
2323
IsTTY: tty,
2424
maxWidth: ttyWidth,
25-
colWidths: []int{},
25+
colWidths: make(map[int]int),
2626
colFuncs: make(map[int]func(string) string),
2727
}
2828
}
@@ -31,14 +31,11 @@ type TTYTablePrinter struct {
3131
out io.Writer
3232
IsTTY bool
3333
maxWidth int
34-
colWidths []int
34+
colWidths map[int]int
3535
colFuncs map[int]func(string) string
3636
}
3737

3838
func (t *TTYTablePrinter) SetContentWidth(col, width int) {
39-
if col == len(t.colWidths) {
40-
t.colWidths = append(t.colWidths, 0)
41-
}
4239
if width > t.colWidths[col] {
4340
t.colWidths[col] = width
4441
}

0 commit comments

Comments
 (0)