table

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TextLeft = Align(iota)
	TextRight
	TextCenter
)

Variables

This section is empty.

Functions

func AlignCenter

func AlignCenter(s string, n int) string

AlignCenter align center

func AlignLeft

func AlignLeft(s string, n int) string

AlignLeft align left

func AlignRight

func AlignRight(s string, n int) string

AlignRight align right

func TableTest

func TableTest(w io.Writer, width int)

Types

type Align

type Align int

type Col

type Col struct {
	Data      string
	Color     string
	BgColor   string
	TextAlign Align
}

func NewCol

func NewCol() *Col

func (*Col) SetBgColor

func (this *Col) SetBgColor(Color string) *Col

func (*Col) SetColor

func (this *Col) SetColor(Color string) *Col

func (*Col) SetTextAlign

func (this *Col) SetTextAlign(align Align) *Col

type Table

type Table struct {
	Header       []*Col
	Rows         [][]*Col // row 行 col 列
	ColumnWidths []int
	ShowHeader   bool
	// contains filtered or unexported fields
}

func NewTable

func NewTable(width int) *Table

func (*Table) AddCol

func (this *Table) AddCol(title string) *Col

顺序添加列名

func (*Table) AddRow

func (this *Table) AddRow(row int, Data *Col)

顺序增加第row行的数据

func (*Table) AddRowByIndex

func (this *Table) AddRowByIndex(row int, Data *Col)

顺序增加第row行的数据 指定index

func (*Table) CalColumnWidths

func (this *Table) CalColumnWidths() error

func (*Table) Fprint

func (this *Table) Fprint(w io.Writer)

打印内容 正序其实打印数据只有一个

func (Table) FprintHeader

func (this Table) FprintHeader(w io.Writer)

func (*Table) FprintOrderDesc

func (this *Table) FprintOrderDesc(w io.Writer)

打印内容 倒序必须是全量数据

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳