table
table copied to clipboard
Coloring rows distorts columns
I'd like to color rows based on some if conditions. I came up with this minimal working example. Adding ANSI colors it seems does not work as expected, i.e. the columns get bit distorted (but without them its OK). Why? Could this be fixed or perhaps coloring rows added as a new feature?
package main
import (
"github.com/rodaine/table"
)
func main() {
tbl := table.New("columnA", "columnB", "columnC")
for i := 0; i < 10; i++ {
color := "\033[34m"
flg := i%2 != 0
if flg {
color = "\033[33m"
}
if flg {
tbl.AddRow(color+"A", "B", "C"+"\033[0m")
} else {
tbl.AddRow(color+"A", "B", "C"+"\033[0m")
}
}
tbl.Print()
}