beautify

package
v0.0.0-...-144b58c Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FmtJson

func FmtJson(v any) string

FmtJson 将 v 转化为 json 并美化输出

func JsonFmt

func JsonFmt(jsonStr string) string

JsonFmt 将 jsonStr 美化输出

func TabColorfulPrint

func TabColorfulPrint(titles []string, data any)

TabColorfulPrint 表格美化炫彩输出

func TabColorfulPrint4Struct

func TabColorfulPrint4Struct(obj any)

TabColorfulPrint4Struct 表格美化炫彩输出(针对结构体切片)

func TabPrint

func TabPrint(titles []string, data any)

TabPrint 表格美化输出

func TabPrint4Struct

func TabPrint4Struct(obj any)

TabPrint4Struct 表格美化输出(针对结构体切片)

Types

type TabFormatter

type TabFormatter struct {
	LeftMargin        int                                     // 左边距设置
	Padding           int                                     // 内边距设置
	Vertex            string                                  // 设置表格中各个顶点的字符串
	TitleTopBorder    byte                                    // 设置表格中表头顶部边框字符
	TitleBottomBorder byte                                    // 设置表格中表头底部边框字符
	DataBorder        byte                                    // 设置表格中数据边框字符
	DataSegment       string                                  // 设置表格中数据分隔符字符串
	GlobalColor       color.Color                             // 全局颜色设置
	TitleColorFun     func(title string) color.Color          // 表头颜色设置
	CellColorFun      func(title, cellVal string) color.Color // 表数据颜色设置
}

TabFormatter 表格格式化配置

type TabFormatterType

type TabFormatterType string

TabFormatterType 表格格式化配置名称

const (
	Gird         TabFormatterType = "grid"         // 网格
	SnowFlake    TabFormatterType = "snowFlake"    // 雪花
	GirdSnow     TabFormatterType = "gridSnow"     // 雪花网格
	Colorful     TabFormatterType = "colorful"     // 炫彩
	RedTitleSnow TabFormatterType = "redTitleSnow" // 红色表头雪花
	GlobalYellow TabFormatterType = "globalYellow" // 全黄表格

)

type TableFmt

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

TableFmt 表格格式化输出对象

func NewTableFmt

func NewTableFmt() *TableFmt

func (*TableFmt) CustomizeTabFormatter

func (my *TableFmt) CustomizeTabFormatter(formatter TabFormatter) *TableFmt

CustomizeTabFormatter 自定义表格格式化配置

func (*TableFmt) Format

func (my *TableFmt) Format(titles []string, data any) string

func (*TableFmt) FormatStruct

func (my *TableFmt) FormatStruct(obj any) string

FormatStruct 根据数据传入的结构体类型,自动解析表头并格式化数据输出

func (*TableFmt) Println

func (my *TableFmt) Println(titles []string, data any)

func (*TableFmt) Println4Struct

func (my *TableFmt) Println4Struct(obj any)

func (*TableFmt) SetTabFormatter

func (my *TableFmt) SetTabFormatter(tabFormatterType TabFormatterType) *TableFmt

SetTabFormatter 设置表格格式化配置

Jump to

Keyboard shortcuts

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