Tabby

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

  • 所有者: cheynewallace/tabby
  • 平台: Linux,Mac,Windows
  • 许可证: MIT License
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

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()
}

主要指标

概览
名称与所有者cheynewallace/tabby
主编程语言Go
编程语言Go (语言数: 1)
平台
许可证MIT License
所有者活动
创建于2018-12-17 23:35:39
推送于2020-12-23 01:20:33
最后一次提交2020-12-23 12:19:22
发布数3
最新版本名称v1.1.1 (发布于 )
第一版名称v1.0.0 (发布于 )
用户参与
星数358
关注者数2
派生数19
提交数24
已启用问题?
问题数6
打开的问题数3
拉请求数2
打开的拉请求数1
关闭的拉请求数0
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?