olekukonko / tablewriter

ASCII table in golang

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Column separator is not aligned

choleraehyq opened this issue · comments

package main

import (
	"os"

	"github.com/olekukonko/tablewriter"
)

func main() {
	data := [][]string{
		{"trace", "14:25:54.123022", "192.219µs"},
		{"  └─traceRun", "14:25:54.123035", "175.245µs"},
		{"    ├─traceRunChild1", "14:25:54.123036", "2.075µs"},
		{"    └─traceRunChild2", "14:25:54.123204", "784ns"},
	}
	table := tablewriter.NewWriter(os.Stdout)
	table.SetHeader([]string{"operation", "startTS", "duration"})
	table.SetAlignment(tablewriter.ALIGN_LEFT)
	table.AppendBulk(data)
	table.Render() // Send output
}

will got

+------------------------+-----------------+-----------+
|       OPERATION        |     STARTTS     | DURATION  |
+------------------------+-----------------+-----------+
| trace                  | 14:25:54.123022 | 192.219µs |
|   └─traceRun         | 14:25:54.123035 | 175.245µs |
|     ├─traceRunChild1 | 14:25:54.123036 | 2.075µs   |
|     └─traceRunChild2 | 14:25:54.123204 | 784ns     |
+------------------------+-----------------+-----------+

which is not aligned.

Goo find do you want to submit a patch ?

Well, I haven't find the reason yet.

Is it still an issue @choleraehyq ? I can not reproduce, even with the exact same code