All contributions

rodaine/table

rodaine/table

A table generator for Go command line apps that aligns columns and lets you format the first column.

Language
Go
GitHub stars
325
Merged changes
1

What we changed

SetRows pads short rows with empty cells to the number of columns, as AddRow does, so the table no longer shows %!s(MISSING) and an empty row no longer panics.

What this work shows

  • CLI output formatting with fmt
  • Go library API consistency
  • Regression tests with testify
What was broken

A short row broke the table

SetRows stored rows shorter than the number of columns as they were. The missing cells printed as %!s(MISSING), and an empty row with a first-column formatter panicked with "index out of range", although the docs promised empty cells.

How we fixed it

Padding like AddRow

A short row is copied into a new slice as long as the header, so the missing columns are empty, as with AddRow. Two tests check the exact output for a short row and that an empty row does not panic.

#67

Merged change 1

  1. #67 fix: pad short rows in SetRows to the number of columns Merged 14 September 2026

What it taught us

Two methods that do the same job must follow the same rule: the docs promised empty cells, AddRow delivered them and SetRows did not. A test that fails without the fix shows that it fixes exactly this bug.

More about this technology: Golang

Other projects we write code for

Describe your project.

A free quote comes back within an hour during working hours.