avyos.dev/pkg/format
package format
Package Overview
No package-level documentation is provided.
| Export Group | Count |
|---|---|
| Constants | 1 |
| Variables | 0 |
| Functions | 9 |
| Types | 3 |
Constants
const (
Reset = "\033[0m"
Bold = "\033[1m"
Dim = "\033[2m"
Underline = "\033[4m"
Black = "\033[30m"
Red = "\033[31m"
Green = "\033[32m"
Yellow = "\033[33m"
Blue = "\033[34m"
Magenta = "\033[35m"
Cyan = "\033[36m"
White = "\033[37m"
BgBlack = "\033[40m"
BgRed = "\033[41m"
BgGreen = "\033[42m"
BgYellow = "\033[43m"
BgBlue = "\033[44m"
BgMagenta = "\033[45m"
BgCyan = "\033[46m"
BgWhite = "\033[47m"
)ANSI color codes
Functions
func Color(color, text string) stringColor applies a color to text if colors are enabled.
func DisableColor()DisableColor disables color output.
func EnableColor()EnableColor enables color output.
func Error(format string, args ...any)Error formats an error message in red.
func Info(format string, args ...any)Info formats an info message in cyan.
func Percent(value, total float64) stringPercent formats a percentage.
func Size(bytes int64) stringSize formats a byte count as a human-readable string.
func Success(format string, args ...any)Success formats a success message in green.
func Warn(format string, args ...any)Warn formats a warning message in yellow.
Types
ProgressBar
type ProgressBar struct {
// contains filtered or unexported fields
}ProgressBar represents a progress bar.
Functions
func NewProgressBar(total int64, width int) *ProgressBarNewProgressBar creates a new progress bar.
Methods
func (p *ProgressBar) Finish()Finish completes the progress bar.
func (p *ProgressBar) Increment(n int64)Increment increments the progress by n.
func (p *ProgressBar) SetLabel(label string)SetLabel sets the label for the progress bar.
func (p *ProgressBar) Update(current int64)Update updates the progress bar.
Table
type Table struct {
// contains filtered or unexported fields
}Table represents a formatted table.
Functions
func NewTable(headers ...string) *TableNewTable creates a new table with the given headers.
Methods
func (t *Table) AddRow(cols ...string)AddRow adds a row to the table.
func (t *Table) Print()Print prints the table to stdout.
func (t *Table) String() stringString returns the formatted table as a string.
Tree
type Tree struct {
// contains filtered or unexported fields
}Tree represents a tree structure for display.
Functions
func NewTree(label string) *TreeNewTree creates a new tree node.
Methods
func (t *Tree) AddChild(child *Tree) *TreeAddChild adds a child node to the tree.
func (t *Tree) AddChildLabel(label string) *TreeAddChildLabel adds a child with the given label.
func (t *Tree) Print()Print prints the tree to stdout.
func (t *Tree) String() stringString returns the tree as a formatted string.