progress

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package progress implements file transfer progress tracking with concurrent progress bars (Tracker) and a no-op implementation (Noop) for when tracking is disabled, both implementing the Trackable interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Noop

type Noop struct{}

Noop is a dummy progress tracker that implements the Trackable interface but performs no tracking. Useful when progress display is disabled.

func NewNoop

func NewNoop() *Noop

NewNoop returns a new instance of Noop.

func (*Noop) Start

func (n *Noop) Start()

Start does nothing.

func (*Noop) TrackProgress

func (n *Noop) TrackProgress(_ string, _, _ int64, rc io.ReadCloser) io.ReadCloser

TrackProgress returns the unmodified stream without wrapping.

func (*Noop) Wait

func (n *Noop) Wait()

Wait does nothing.

type Trackable

type Trackable interface {
	Start()
	Wait()
	TrackProgress(src string, currentSize, totalSize int64, stream io.ReadCloser) io.ReadCloser
}

Trackable defines the interface for progress tracking implementations.

type Tracker

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

Tracker tracks multiple concurrent progress bars and renders them.

func New

func New() *Tracker

New initializes and returns a Tracker with default styles and settings.

func (*Tracker) Start

func (pt *Tracker) Start()

Start begins rendering progress bars in a separate goroutine.

func (*Tracker) TrackProgress

func (pt *Tracker) TrackProgress(
	src string,
	currentSize, totalSize int64,
	stream io.ReadCloser,
) io.ReadCloser

TrackProgress wraps the given ReadCloser to update the progress bar during read and on close.

func (*Tracker) Wait

func (pt *Tracker) Wait()

Wait waits for all tracked readers to finish and stops rendering once done.

Jump to

Keyboard shortcuts

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