tableify

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 10, 2018 License: Apache-2.0 Imports: 3 Imported by: 0

README

go-tableify

Go Report Card GoDoc

Pretty console printing of tabular data

Installation

Make sure you have a working Go environment. Follow the Go install instructions.

To install go-tableify, simply run:

go get github.com/subchen/go-tableify

Example

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

Output

NAME         FILES   UPDATED
-----------------------------------------
yum-repo     45      2018-01-06T07:45:22Z
deb-repo     12      2018-01-06T08:05:09Z

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Table

type Table struct {
	Margin    int
	SplitLine bool
	EmptyText string

	FormatFunc func(header string, value interface{}) string
	// contains filtered or unexported fields
}

func New

func New() *Table

func (*Table) AddRow

func (t *Table) AddRow(data ...interface{})

func (*Table) AddRowList

func (t *Table) AddRowList(rows ...[]string)

func (*Table) Print

func (t *Table) Print()

func (*Table) SetHeaders

func (t *Table) SetHeaders(headers ...string)

func (*Table) SetWidths

func (t *Table) SetWidths(widths ...int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL