Gotabulate - Easily pretty-print tabular data
Summary
Go-Tabulate - Generic Go Library for easy pretty-printing of tabular data.
Installation
go get github.com/bndr/gotabulate
Description
Supported data types:
- 2D Array of
Int
,Int64
,Float64
,String
,interface{}
- Map of
String
,interface{}
(Keys will be used as header)
Usage
// Create Some Fake Rows
row_1 := []interface{}{"john", 20, "ready"}
row_2 := []interface{}{"bndr", 23, "ready"}
// Create an object from 2D interface array
t := gotabulate.Create([][]interface{}{row_1, row_2})
// Set the Headers (optional)
t.SetHeaders([]string{"age", "status"})
// Set the Empty String (optional)
t.SetEmptyString("None")
// Set Align (Optional)
t.SetAlign("right")
// Print the result: grid, or simple
fmt.Println(t.Render("grid"))
+---------+--------+-----------+