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

output

package
v2.17.1 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: BSD-3-Clause Imports: 25 Imported by: 0

Documentation

Overview

Package output provides styled messages and terminal tables for the CLI.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bytes added in v2.6.0

func Bytes(value int64) string

Bytes renders a signed byte count in human-readable form.

func Configure added in v2.15.0

func Configure(stdout, stderr io.Writer, jsonMode, noColor bool, label string)

Configure binds output to the current command's writers and output mode.

func Confirm added in v2.15.0

func Confirm(ctx context.Context, input io.Reader, out io.Writer, label string) (bool, error)

Confirm requires terminal input, using a selector or line input depending on the output terminal.

func CoordinatedWriter added in v2.15.0

func CoordinatedWriter(w io.Writer) io.Writer

CoordinatedWriter clears loading while another writer uses the terminal.

func Copy added in v2.15.0

func Copy(ctx context.Context, dst io.Writer, src io.Reader, total int64, label string, enabled bool) (int64, error)

Copy copies a transfer while reporting bytes, or activity for unknown totals.

func Header(format string, a ...any)

Header prints a purple section heading. A leading newline separates the heading from previous output.

func Info

func Info(format string, a ...any)

Info prints an info message in purple. Format specifiers work like fmt.Printf; a leading newline separates messages.

func IsTerminal added in v2.15.0

func IsTerminal(value any) bool

IsTerminal checks the actual writer, including terminal capability.

func KeyValue

func KeyValue(key string, value any)

KeyValue prints a key-value pair with the muted aligned labels and neutral values. Use it for structured details and configuration values.

func ReadWithContext added in v2.15.0

func ReadWithContext[T any](ctx context.Context, input io.Reader, read func(io.Reader) (T, error)) (T, error)

ReadWithContext reads input until read returns or ctx is canceled. Pollable files cancel in place; other blocking readers use an asynchronous read.

func Secret added in v2.15.0

func Secret(ctx context.Context, input io.Reader, out io.Writer, label, flagName string) (string, error)

Secret reads a masked value from a terminal, or one line from piped input. An empty value asks the caller to pass flagName instead.

func Showing

func Showing(shown int, total int64, label string)

Showing prints a pagination summary in the form "Showing: shown/total label".

func StartLoading added in v2.15.0

func StartLoading(ctx context.Context) *tracker

StartLoading tracks the current command while a request is in progress.

func StartTracker added in v2.15.0

func StartTracker(ctx context.Context, out io.Writer, enabled bool, labels ...string) *tracker

StartTracker renders a checklist only for interactive text output.

func Stderr added in v2.15.0

func Stderr() io.Writer

Stderr returns the current command's diagnostic writer.

func Stdout added in v2.15.0

func Stdout() io.Writer

Stdout returns the current command's result writer.

func Success

func Success(format string, a ...any)

Success prints a success message in green. Format specifiers work like fmt.Printf; a leading newline separates messages.

func SuspendProgress added in v2.15.0

func SuspendProgress() func()

SuspendProgress pauses every active tracker until the returned function runs.

func Table

func Table(headers []string, rows [][]string) error

Table prints a formatted table with headers and rows. Rendering uses Lip Gloss table styles with zebra-striped rows.

func TintEnabled

func TintEnabled(value string) string

TintEnabled applies tints for enabled/disabled values.

func TintInsecure

func TintInsecure(value string) string

TintInsecure applies warning tints for insecure values.

func TintStatus

func TintStatus(value string) string

TintStatus applies semantic status coloring to a value.

func TintYesNo

func TintYesNo(value string) string

TintYesNo applies tints for yes/no style values.

func UnsignedBytes added in v2.6.0

func UnsignedBytes(value uint64) string

UnsignedBytes renders an unsigned byte count in human-readable form.

func Warning

func Warning(format string, a ...any)

Warning prints a warning message in yellow. Format specifiers work like fmt.Printf; a leading newline separates messages.

func WriteError added in v2.15.0

func WriteError(w io.Writer, err error)

WriteError renders the command error once through Fang's error handler.

Types

This section is empty.

Jump to

Keyboard shortcuts

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