progress

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package progress renders lightweight, interactive progress feedback to a writer (typically stderr). Output goes to stderr so it never corrupts the summary written to stdout or an output file, and rendering is a no-op when disabled, so callers don't need to special-case quiet or non-terminal runs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsTerminal

func IsTerminal(f *os.File) bool

IsTerminal reports whether f refers to a character device (an interactive terminal), meaning animated progress is appropriate.

Types

type Reporter

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

Reporter renders progress lines to a writer using carriage returns so each update overwrites the previous one in place. A nil or disabled Reporter turns every method into a no-op.

func New

func New(w io.Writer, enabled bool) *Reporter

New returns a Reporter writing to w. Progress is only rendered when enabled; pass IsTerminal(os.Stderr) so piped or redirected runs stay clean.

func (*Reporter) Done

func (r *Reporter) Done(msg string)

Done overwrites the current line with msg and terminates it with a newline, leaving a final status visible.

func (*Reporter) Spin

func (r *Reporter) Spin(label string) (stop func())

Spin starts an indeterminate spinner for a phase whose progress can't be measured (e.g. type-checking the dependency tree) and returns a stop function. Calling stop ends the animation and clears the line; it is safe to call once and is a no-op when the Reporter is disabled.

func (*Reporter) Step

func (r *Reporter) Step(label string, current, total int)

Step renders a determinate progress bar, e.g. "Parsing files [████░░] 12/40". total <= 0 renders an empty bar.

Jump to

Keyboard shortcuts

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