table

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Color constants for ANSI colors
	ColorBlack   = 0
	ColorRed     = 1
	ColorGreen   = 2
	ColorYellow  = 3
	ColorBlue    = 4
	ColorMagenta = 5
	ColorCyan    = 6
	ColorWhite   = 7
)

Colors for styling table content

Variables

This section is empty.

Functions

func Blue

func Blue(content string) string

Blue returns text colored in blue

func CreateColoredCell

func CreateColoredCell(content string, color int) string

CreateColoredCell returns a cell with the specified color

func Green

func Green(content string) string

Green returns text colored in green

func Print

func Print(header []string, body [][]string)

Print outputs a table to stdout with default styling

func PrintWithOptions

func PrintWithOptions(writer io.Writer, header []string, body [][]string, options TableOptions)

PrintWithOptions outputs a table with the provided configuration options

func PrintWithWriter

func PrintWithWriter(writer io.Writer, header []string, body [][]string)

PrintWithWriter outputs a table to the provided writer with default styling

func Red

func Red(content string) string

Red returns text colored in red

func RenderToString

func RenderToString(header []string, body [][]string) string

RenderToString renders a table and returns it as a string

func Yellow

func Yellow(content string) string

Yellow returns text colored in yellow

Types

type TableOptions

type TableOptions struct {
	// AutoWrapText controls text wrapping in cells
	AutoWrapText bool
	// AutoFormatHeaders controls header formatting
	AutoFormatHeaders bool
	// HeaderAlignment sets the alignment for header cells
	HeaderAlignment int
	// CellAlignment sets the alignment for non-header cells
	CellAlignment int
	// UseBorders enables table borders
	UseBorders bool
	// Padding sets the padding between columns
	Padding string
	// FooterData adds a footer row to the table
	FooterData []string
	// Caption sets a caption for the table
	Caption string
}

TableOptions provides configuration for table rendering

func DefaultOptions

func DefaultOptions() TableOptions

DefaultOptions returns the default table formatting options

Jump to

Keyboard shortcuts

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