A rudimentary terminal table rendering library for Go using
charmbracelet/lipgloss.
This library has been implemented for
github.com/lsg551/matricula-online
and its specific requirements. Although there are much better and more mature
alternatives, most were missing a crucial feature I needed: Edge-to-edge layout
or rendering tables that take up the full width of the terminal and have some
columns that grow to fill the remaining space. You can see an example of this
here.
Therefore, you should probably NOT use this library and one of the great alternatives instead, such as:
github.com/olekukonko/tablewriteris an extensive and mature library for rendering tables in the terminal.lipglossitself has a minimal implementation to render tables.
go get github.com/lsg551/tabulaimport (
"github.com/lsg551/tabula"
)
func main() {
table := tabula.New([]tabula.Column{
tabula.NewColumn("Name"),
tabula.NewColumn("Age"),
tabula.NewColumn("City"),
})
table.AddRow("Alice", "30", "London")
table.AddRow("Bob", "25", "Berlin")
println(table.String())
}Calling table.String() or table.Render() will render the table as a string,
which can be printed to the terminal. The above example will look like this:
==========================
Name Age City
==========================
Alice 30 London
Bob 25 Berlin
More examples can be found in the examples directory.
Docs are available on pkg.go.dev.
This project is licensed under GPL-3.0 License.