diff --git a/table/table.go b/table/table.go index 278077f623f..7de2d46343a 100644 --- a/table/table.go +++ b/table/table.go @@ -18,6 +18,7 @@ package table import ( "fmt" "math" + "strings" ) // ColumnWidthMode is used to configure columns type @@ -127,7 +128,7 @@ func (t *Table) Render() string { res := "" for _, row := range t.rows { - separator := "" + line := "" for x, cell := range row.cells { selectedWidth := widths[x] if x < len(t.columnsWidthMode) { @@ -141,11 +142,13 @@ func (t *Table) Render() string { if selectedWidth < minimum[x] { selectedWidth = minimum[x] } - res += separator - res += cell.Pad(selectedWidth) - separator = " " + if x > 0 { + line += " " + } + line += cell.Pad(selectedWidth) } - res += "\n" + + res += strings.TrimRight(line, " ") + "\n" } return res }