Skip to content

Instantly share code, notes, and snippets.

@anirudh-chhangani
Created May 19, 2019 17:29
Show Gist options
  • Save anirudh-chhangani/83f215045f24f8f47780b43268389673 to your computer and use it in GitHub Desktop.
Save anirudh-chhangani/83f215045f24f8f47780b43268389673 to your computer and use it in GitHub Desktop.
tabular struct
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)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment