Documentation
¶
Overview ¶
ItemsTable 用于展示 Array 和 Slice 类型数据
支持以下特性:
样式
- 设置边框格式
- 自定义颜色
- 开启/关闭表格内边框
列
- 开启/关闭自动编号
- 设置最大宽度
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var StyleBold = Style{
"┏", "┳", "┓",
"┣", "╋", "┫",
"┗", "┻", "┛",
"━", "┃",
}
StyleBold renders a table like below:
┏━━━━┳━━━━━━━┳━━━━━┓ ┃ Id ┃ Name ┃ Age ┃ ┣━━━━╋━━━━━━━╋━━━━━┫ ┃ 1 ┃ name1 ┃ 1 ┃ ┃ 2 ┃ name2 ┃ 10 ┃ ┗━━━━┻━━━━━━━┻━━━━━┛
View Source
var StyleDefault = Style{
"+", "+", "+",
"+", "+", "+",
"+", "+", "+",
"-", "|",
}
StyleDefault renders a table like below:
+----+-------+-----+ | Id | Name | Age | +----+-------+-----+ | 1 | name1 | 1 | | 2 | name2 | 10 | +----+-------+-----+
View Source
var StyleDouble = Style{
"╔", "╦", "╗",
"╠", "╬", "╣",
"╚", "╩", "╝",
"═", "║",
}
StyleBold renders a table like below:
╔════╦═══════╦═════╗ ║ Id ║ Name ║ Age ║ ╠════╬═══════╬═════╣ ║ 1 ║ name1 ║ 1 ║ ║ 2 ║ name2 ║ 10 ║ ╚════╩═══════╩═════╝
View Source
var StyleLight = Style{
"┌", "┬", "┐",
"├", "┼", "┤",
"└", "┴", "┘",
"─", "│",
}
StyleLight renders a table like below:
┌────┬───────┬─────┐ │ Id │ Name │ Age │ ├────┼───────┼─────┤ │ 1 │ name1 │ 1 │ │ 2 │ name2 │ 10 │ └────┴───────┴─────┘
View Source
var StyleRounded = Style{
"╭", "┬", "╮",
"├", "┼", "┤",
"╰", "┴", "╯",
"─", "│",
}
StyleRounded renders a table like below:
╭────┬───────┬─────╮ │ Id │ Name │ Age │ ├────┼───────┼─────┤ │ 1 │ name1 │ 1 │ │ 2 │ name2 │ 10 │ ╰────┴───────┴─────╯
Functions ¶
This section is empty.
Types ¶
type ItemsTable ¶
type ItemsTable struct { Name string Headers []H Items interface{} InlineBorder bool AutoIndex bool // contains filtered or unexported fields }
func NewItemsTable ¶
func NewItemsTable(titles []string, items interface{}) *ItemsTable
func (*ItemsTable) EnableAutoIndex ¶
func (t *ItemsTable) EnableAutoIndex() *ItemsTable
func (*ItemsTable) Render ¶
func (t *ItemsTable) Render() (string, error)
func (*ItemsTable) SetColor ¶
func (t *ItemsTable) SetColor(attributes ...color.Attribute) *ItemsTable
func (*ItemsTable) SetStyle ¶
func (t *ItemsTable) SetStyle(style Style, colors ...color.Attribute) *ItemsTable
Click to show internal directories.
Click to hide internal directories.