Tabby

超简单 Golang 表格的小型库。「A tiny library for super simple Golang tables」

  • Owner: cheynewallace/tabby
  • Platform: Linux,Mac,Windows
  • License:: MIT License
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

cover.run
Mentioned in Awesome Go

Tabby

A tiny library for super simple Golang tables

Get Tabby

go get github.com/cheynewallace/tabby

Import Tabby

import "github.com/cheynewallace/tabby"

Tabby is a tiny (around 70 lines of code) efficient libary for writing extremely simple table based terminal output in Golang.

Many table libraries out there are overly complicated and packed with features you don't need. If you simply want to write clean output to your terminal in table format with minimal effort, Tabby is for you.

Typical examples

  • Writing simple tables with heading and tab spaced columns
  • Writing log lines to the terminal with evenly spaced columns

Example With Heading

t := tabby.New()
t.AddHeader("NAME", "TITLE", "DEPARTMENT")
t.AddLine("John Smith", "Developer", "Engineering")
t.Print()

Output

NAME        TITLE      DEPARTMENT
----        -----      ----------
John Smith  Developer  Engineering

Example Without Heading

t := tabby.New()
t.AddLine("Info:", "WEB", "Success 200")
t.AddLine("Info:", "API", "Success 201")
t.AddLine("Error:", "DATABASE", "Connection Established")
t.Print()

Output

Info:   WEB       Success 200
Info:   API       Success 201
Error:  DATABASE  Connection Established

Example With Custom tabWriter

w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
t := tabby.NewCustom(w)

Full Example

package main

import "github.com/cheynewallace/tabby"

func main() {
	t := tabby.New()
	t.AddHeader("NAME", "TITLE", "DEPARTMENT")
	t.AddLine("John Smith", "Developer", "Engineering")
	t.Print()
}

Main metrics

Overview
Name With Ownercheynewallace/tabby
Primary LanguageGo
Program languageGo (Language Count: 1)
Platform
License:MIT License
所有者活动
Created At2018-12-17 23:35:39
Pushed At2020-12-23 01:20:33
Last Commit At2020-12-23 12:19:22
Release Count3
Last Release Namev1.1.1 (Posted on )
First Release Namev1.0.0 (Posted on )
用户参与
Stargazers Count358
Watchers Count2
Fork Count19
Commits Count24
Has Issues Enabled
Issues Count6
Issue Open Count3
Pull Requests Count2
Pull Requests Open Count1
Pull Requests Close Count0
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private