# go-tableify **Repository Path**: mirrors_subchen/go-tableify ## Basic Information - **Project Name**: go-tableify - **Description**: Pretty console printing of tabular data - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-08-18 - **Last Updated**: 2026-05-16 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # go-tableify [![Go Report Card](https://goreportcard.com/badge/github.com/subchen/go-tableify)](https://goreportcard.com/report/github.com/subchen/go-tableify) [![GoDoc](https://godoc.org/github.com/subchen/go-tableify?status.svg)](https://godoc.org/github.com/subchen/go-tableify) Pretty console printing of tabular data ## Installation Make sure you have a working Go environment. Follow the [Go install instructions](http://golang.org/doc/install.html). To install `go-tableify`, simply run: ``` go get github.com/subchen/go-tableify ``` ## Example ### Manunal Set ```go package main import ( "github.com/subchen/go-tableify" ) func main() { t := tableify.New() t.SetHeaders("Name", "Files", "Updated") t.SetWidths(10, 0, 0) // optional t.EmptyText = "no data in table" t.AddRow("yum-repo", 45, "2018-01-06T07:45:22Z") t.AddRow("deb-repo", 12, "2018-01-06T08:05:09Z") t.Print() } ``` ### Using Struct ```go package main import ( "github.com/subchen/go-tableify" ) type Repo struct { Name string `json:"name" tableify:"-"` Desc string `json:"desc"` Files int `json:"files" tableify:"-,5"` LastUpdated string `json:"lastUpdated" tableify:"Updated"` } func main() { repolist := []Repo{ { Name: "yum-repo", Files: 45, LastUpdated: "2018-01-06T07:45:22Z", }, { Name: "deb-repo", Files: 12, LastUpdated: "2018-01-06T08:05:09Z", }, } t := tableify.New() t.SetHeadersFromStruct(new(Repo)) t.AddRowObjectList(repolist) t.Print() } ``` Struct Field Tag formats: - `name` or `-` eg: `tableify:"-"`, `tableify:"NAME"` - `name,width` eg: `tableify:"-,20"` - `name,width,format` eg: `tableify:"-,0,%.2f"` ## Output ``` Name Files Updated ----------------------------------------- yum-repo 45 2018-01-06T07:45:22Z deb-repo 12 2018-01-06T08:05:09Z ```