progress

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 6 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package progress owns spinners and bars. Apps never construct the underlying widgets directly: every widget shares one caller-provided writer (the render output), so concurrent spinners, bars, and logs cannot garble each other at the file level.

Live-tree rule: stop (or never start) InteractiveRenderer drawing while a spinner or bar runs, and resume after. The widgets draw with their own escape traffic, which fights the tree's incremental redraws. Pipes, CI, and dumb terminals need no pausing: nothing live draws there.

Terminal rule: spinners animate only when their destination is a terminal; Start elsewhere is a safe no-op. Bars always render (they degrade to plain lines), so CI logs keep full progress.

Frame rule: braille dots on capable terminals, plain ASCII spinners (|/-\ differences) on legacy Windows consoles and anywhere else style.Emoji() is false.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bar

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

Bar draws a labeled progress bar to w.

func NewBar

func NewBar(w io.Writer, total int, description string) *Bar

NewBar builds a bar for total units with a description prefix. Narrow terminals shrink the bar to fit instead of wrapping.

func (*Bar) Add

func (b *Bar) Add(n int) error

Add advances n units, redrawing the bar.

func (*Bar) Finish

func (b *Bar) Finish() error

Finish fills the bar and ends the line.

type Spinner

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

Spinner draws a message with an animated prefix until Stop.

func NewSpinner

func NewSpinner(w io.Writer, message string, emoji bool) *Spinner

NewSpinner builds a stopped spinner writing to w. Pass style.Emoji() as emoji to pick dots vs ASCII frames.

Animation runs only when the destination is a terminal: Start on a pipe, file, or CI log is a safe no-op (nothing draws, nothing hangs), so callers never branch on interactivity themselves.

func (*Spinner) Active

func (s *Spinner) Active() bool

Active reports whether the spinner is animating.

func (*Spinner) Start

func (s *Spinner) Start()

Start begins animation. The message stays until Stop.

func (*Spinner) Stop

func (s *Spinner) Stop()

Stop ends animation and restores the line.

Jump to

Keyboard shortcuts

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