package main import ( "bytes" "fmt" "github.com/fatih/structs" "github.com/olekukonko/tablewriter" ) type printable struct { A int B string } func (p printable) GoString() string { _ = structs.Values(p) fields := structs.Fields(p) var buf []byte _table := tablewriter.NewWriter(bytes.NewBuffer(buf)) _table.SetHeader(fields) return "" } func main(){ a := printable{123, "lala"} fmt.Printf("%#v", a) }