Skip to content

jhunt/go-table

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-table

Travis CI

A small library for formatting fluid tables for the CLI.

Usage

You start with a table.NewTable(), to define your headers:

t := table.NewTable("#", "Name", "Notes", "Status")

Then, for each thing you want to tabularize, just call t.Row(), passing it a nil first argument and the values for each column:

t.Row(nil, 1, "Foo", "lorem ipsum dolor sit amet...", "GOOD")
t.Row(nil, 2, "Bar", "you can even have\nembedded newlines...", "GOOD")

Finally, to print it, call t.Output(), passing it the io.Writer you want it to print to (like os.Stdout):

t.Output(os.Stdout)

Those four lines render the following table, effortlessly:

#  Name  Notes                          Status
=  ====  =====                          ======
1  Foo   lorem ipsum dolor sit amet...  GOOD
2  Bar   you can even have              GOOD
         embedded newlines...

About

A Terminal Table Formatting Library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages