GoStruct2Table

format your struct like a table.

Installing

$ go get -u -v github.com/runningzyp/GoStruct2Table

Simple Example

import "github.com/runningzyp/GoStruct2Table/parser"

var p = struct {
	Name    string
	Age     int
	Address string
}{
	Name:    "xiangcai",
	Age:     18,
	Address: "shanghai",
}

parser.Parse(p)

+----------+--------------------+---------------------------+
|ROOT      |KEY                 |VALUE                      |
+----------+--------------------+---------------------------+
|          |Name                |xiangcai                   |
|          |Age                 |18                         |
|          |Address             |shanghai                   |
+----------+--------------------+---------------------------+

Nested:

type Nested struct {
	Core int
}
var p = struct {
	Name    string
	Age     int
	Address string
	Nested  Nested
}{
	Name:    "xiangcai",
	Age:     18,
	Address: "shanghai",
	Nested:  Nested{Core: 1},
}

+----------+--------------------+---------------------------+
|ROOT      |KEY                 |VALUE                      |
+----------+--------------------+---------------------------+
|          |Name                |xiangcai                   |
|          |Age                 |18                         |
|          |Address             |shanghai                   |
+----------+--------------------+---------------------------+
|Nested    |Core                |1                          |
+----------+--------------------+---------------------------+

GitHub

View Github