Skip to content

Commit

Permalink
Fix crash with empty table
Browse files Browse the repository at this point in the history
  • Loading branch information
mislav committed Nov 20, 2019
1 parent 02b1f60 commit 9fc80a1
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions utils/table_printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
}
Expand All @@ -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
}
Expand Down

0 comments on commit 9fc80a1

Please sign in to comment.