Help us shape the future of Go! Take the 2026 Go Developer Survey

fmtx

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: MIT Imports: 2 Imported by: 16

README

fmtx: beautiful and simple text interfaces

Documentation

Index

Constants

View Source
const (
	Reset    = "\033[0m"
	Red      = "\033[91m"
	Green    = "\033[92m"
	Yellow   = "\033[93m"
	Blue     = "\033[94m"
	Magenta  = "\033[95m"
	Cyan     = "\033[96m"
	Dim      = "\033[2m"
	Bold     = "\033[1m"
	BgRed    = "\033[41m"
	BgGreen  = "\033[42m"
	BgYellow = "\033[43m"
)

Variables

View Source
var EnableColor = true

Functions

func BgGreenS

func BgGreenS(s string) string

func BgRedS

func BgRedS(s string) string

func BlueS

func BlueS(s string) string

func BoldS

func BoldS(s string) string

func ColorizeMinMax added in v0.1.2

func ColorizeMinMax[T int | float32 | float64](s string, v, min, max T, minC, maxC string) string

func DimS

func DimS(s string) string

func GreenS

func GreenS(s string) string

func RedS

func RedS(s string) string

func VolumeBar

func VolumeBar[T int | int32 | int64 | float32 | float64](v, max T, width int) string

func YellowS

func YellowS(s string) string

Types

type Alignment

type Alignment uint8
const (
	AlignLeft Alignment = iota
	AlignRight
)

func (Alignment) Write

func (a Alignment) Write(out interface{ WriteString(string) (int, error) }, s string, width int)

type TablCol

type TablCol struct {
	Header    string
	Alignment Alignment
	Width     int
}

func (TablCol) Write

func (s TablCol) Write(out interface{ WriteString(string) (int, error) }, v string)

type TableWriter

type TableWriter struct {
	Indent string
	Cols   []TablCol
	Out    interface {
		WriteString(s string) (n int, err error)
	}
}

TableWriter provides simple table formatting with ANSI color support. Values that are too long will get truncated into column width.

func (TableWriter) WriteHeader

func (s TableWriter) WriteHeader()

func (TableWriter) WriteHeaderLine

func (s TableWriter) WriteHeaderLine()

func (TableWriter) WriteRow

func (s TableWriter) WriteRow(vs ...string)

func (TableWriter) WriteSubHeader

func (s TableWriter) WriteSubHeader(vs ...string)

Jump to

Keyboard shortcuts

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