table

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

example:

1. NewTable().Header([]string{"h1", "h2"}).Data([][]string{{"d1", "d2"}, {"d3","d4"}}).Flush() >>> H1 H2 d1 d2 d3 d4

NewTable(WithVertical()).Header([]string{"h1", "h2"}).Data([][]string{{"d1", "d2"}, {"d3","d4"}}).Flush()

>>> H1 d1 d3 H2 d2 d4

  1. 指定输出 NewTable(WithWriter(os.Stderr))

// TODO: 对中文的对齐有问题(中文可以显示在最后一列来避免 = =||)

// NOTE: 没有设置 WithVertical 时,标题行 全部都是大写 设置 WithVertical 时,标题列 为首字母大写

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDataHeaderLength = errors.New("len(header) != len(data[i])")
)

Functions

This section is empty.

Types

type OpOption

type OpOption func(*tableOption)

func WithVertical

func WithVertical() OpOption

func WithWriter

func WithWriter(w io.Writer) OpOption

type Table

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

func NewTable

func NewTable(ops ...OpOption) *Table

func (*Table) Data

func (t *Table) Data(data [][]string) *Table

func (*Table) Flush

func (t *Table) Flush() error

func (*Table) Header

func (t *Table) Header(header []string) *Table

Jump to

Keyboard shortcuts

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