olekukonko / tablewriter

ASCII table in golang

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Long text cannot be wrapped automatically

StevyZheng opened this issue · comments

Long text cannot be wrapped automatically and cannot be fixed by setting the width.
Can you help me with this problem? Thanks!

image
image

the code:

arr := lib.Analysis("haha.txt")
arrLen := arr.Size()
var data [][]string
it := arr.Iterator()
for it.Next() {
row := make([]string, 2, 2)
row[0] = strconv.FormatInt(it.Value().(*lib.RowLog).Index, 10)
row[1] = it.Value().(*lib.RowLog).Data
data = append(data, row)
}
table := tablewriter.NewWriter(os.Stdout)
table.SetHeader([]string{"index", "errMsg"})
table.SetRowLine(true)
table.SetFooter([]string{"Total", strconv.Itoa(arrLen)})
table.SetColMinWidth(1, 30)
for _, v := range data {
table.Append(v)
}
table.Render()