Skip to content

Simple library to tabulate your slice/array data with olekukonko/tablewriter

Notifications You must be signed in to change notification settings

aca/go-tabulate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

go-tabulate

PkgGoDev

Simple library to tabulate your slice/array data with olekukonko/tablewriter.

Use tabulate struct tag to customize table header.

  • Print(in interface{}) simply prints slice to stdout in markdown format

    type Human struct {
      Username string `tabulate:"name"`
      Age      int 
      Secret   string `tabulate:"-"`
    }
    
    d := []Human{
      {"john", 3, "password1"},
      {"kim", 3, "password2"},
    }
    
    tabulate.Print(d)
    
    | NAME | AGE |
    |------|-----|
    | john |   3 |
    | kim  |   3 |
    
  • AppendBulk(table *tablewriter.Table, in interface{}) instead of tablewriter's AppendBulk

    table := tablewriter.NewWriter(os.Stdout)
    tabulate.AppendBulk(table, d)
    table.Render()
    
    +-------+-----+
    | NAME  | AGE |
    +-------+-----+
    | john  |   3 |
    | kim   |   3 |
    +-------+-----+
    

About

Simple library to tabulate your slice/array data with olekukonko/tablewriter

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages