progress

package
v0.5.6 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2025 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package progress provides utilities for tracking progress of operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetupProgressReader

func SetupProgressReader(content io.Reader, progressFunc ProgressFunc) (io.Reader, error)

SetupProgressReader creates a progress reader if needed. SetupProgressReader creates a progress-aware reader that wraps the provided io.Reader. It returns an error if the input reader is nil, and if the progress function is nil, the original reader is returned unmodified. If the reader supports seeking (io.Seeker), it determines the total size of the content by seeking to the end and then restoring the original position before wrapping it with NewReader.

Types

type ProgressFunc

type ProgressFunc func(current, total int64, message string)

- message: A descriptive message about the current operation.

type Reader

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

Reader wraps an io.Reader to track progress.

func NewReader

func NewReader(reader io.Reader, total int64, progressFunc ProgressFunc) *Reader

NewReader creates a new progress-tracking Reader that wraps the provided io.Reader. It uses the given total byte count to monitor progress and, if provided, calls the progressFunc with updates that include the current progress and a descriptive message.

func (*Reader) Read

func (r *Reader) Read(p []byte) (n int, err error)

Read implements the io.Reader interface.

Jump to

Keyboard shortcuts

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