프로젝트
GitHub에서 보기
cheynewallace/tabby
소개
Go에서 아주 간단하게 표를 만들 수 있는 작은 라이브러리입니다.
개발 도구측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalTabby
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
- Default writer (os.Stdout) 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()
}
- File writer example:
package main
import (
"os"
"text/tabwriter"
"github.com/cheynewallace/tabby"
)
func main() {
fd, _ := os.OpenFile("test.txt", os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0644)
defer fd.Close()
w := tabwriter.NewWriter(fd, 0, 0, 4, ' ', 0)
t := tabby.NewCustom(w)
t.AddHeader("NAME", "TITLE", "DEPARTMENT")
t.AddLine("John Smith", "Developer", "Engineering")
t.Print()
}
관련 프로젝트 살펴보기
불러오는 중…