progress

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package progress provides utilities for displaying progress bars in the terminal.

This package includes a sample [ProgressBar] implementation that can be used with the http-client's progress callbacks to display upload/download progress.

Basic Usage

bar := progress.NewProgressBar("Downloading", totalBytes)
opt := options.New()
opt.Progress.OnDownload = func(bytesRead, totalBytes int64) {
    bar.Update(bytesRead)
}
resp, err := client.Get(url, opt)
bar.Finish()

Terminal Width

The progress bar automatically adapts to the terminal width. If the terminal size cannot be determined, it defaults to 80 characters.

Custom Progress Tracking

For custom progress handling, use the callbacks directly without this package:

opt := options.New()
opt.Progress.OnUpload = func(bytesRead, totalBytes int64) {
    pct := float64(bytesRead) / float64(totalBytes) * 100
    fmt.Printf("\rProgress: %.1f%%", pct)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateProgressFunc

func CreateProgressFunc() func(int64, int64)

CreateProgressFunc creates a progress reporting function to display upload/download progress in the terminal. It provides real-time feedback, including the percentage completed, speed, and estimated time remaining (ETA).

Types

This section is empty.

Jump to

Keyboard shortcuts

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