texttable

package module
v0.0.0-...-eae5d13 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2020 License: MIT Imports: 5 Imported by: 4 modules, 3 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

go-texttable

Sample Code

package main

import "github.com/syohex/go-texttable"
import "fmt"

func main () {
	tbl := &texttable.TextTable{}
	tbl.SetHeader("Country", "Capital")

	tbl.AddRow("United States of America", "Washington D.C")
	tbl.AddRow("France", "Paris")
	tbl.AddRow("United Kingdom", "London")
	tbl.AddRow("Japan", "Tokyo")
	tbl.AddRow("Taiwan", "Taipei")

	fmt.Println(tbl.Draw())
}

Output of above code is

go-texttable1

go-texttable also supports multibyte characters such as Japanese.

package main

import "github.com/syohex/go-texttable"
import "fmt"

func main () {
	tbl := &texttable.TextTable{}
	tbl.SetHeader("プログラミング言語", "よみがな", "作者")

	tbl.AddRow("Python", "ぱいそん", "グイド・ヴァンロッサム")
	tbl.AddRow("Perl", "ぱーる", "ラリーウォール")
	tbl.AddRow("Ruby", "るびぃ", "まつもとゆきひろ")
	tbl.AddRow("Erlang", "あーらん", "ジョーアームストロング")
	tbl.AddRow("D言語", "でぃーげんご", "ウォルター・ブライト")

	fmt.Println(tbl.Draw())
}

go-texttable2

Documentation

Index

Constants

View Source
const (
	ALIGN_LEFT cellAlignment = iota
	ALIGN_RIGHT
)
View Source
const (
	ROW_LINE rowType = iota
	ROW_CELLS
)

Variables

This section is empty.

Functions

This section is empty.

Types

type TextTable

type TextTable struct {
	// contains filtered or unexported fields
}

func (*TextTable) AddRow

func (t *TextTable) AddRow(strs ...string) error

AddRow adds column from strings given

func (*TextTable) AddRowLine

func (t *TextTable) AddRowLine() error

AddRowLine adds row border

func (*TextTable) Draw

func (t *TextTable) Draw() string

Draw constructs text table from receiver and returns it as string

func (*TextTable) SetHeader

func (t *TextTable) SetHeader(headers ...string) error

SetHeader adds header row from strings given

Jump to

Keyboard shortcuts

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