progress

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package progress provides progress tracking for I/O operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Callback

type Callback func(current, total int64)

Callback is called with current bytes processed and total size. For uploads, current is bytes written. For downloads, current is bytes read.

type Reader

type Reader struct {
	R        io.Reader
	Total    int64
	OnUpdate Callback
	// contains filtered or unexported fields
}

Reader wraps an io.Reader to report read progress. This is useful for tracking download progress.

func NewReader

func NewReader(r io.Reader, total int64, onUpdate Callback) *Reader

NewReader creates a progress reader wrapping the given reader. total is the expected total bytes (use -1 if unknown). onUpdate is called after each Read with current and total bytes.

func (*Reader) BytesRead

func (pr *Reader) BytesRead() int64

BytesRead returns the total bytes read so far.

func (*Reader) Read

func (pr *Reader) Read(p []byte) (int, error)

Read implements io.Reader, tracking bytes read and calling the progress callback.

type Writer

type Writer struct {
	W        io.Writer
	Total    int64
	OnUpdate Callback
	// contains filtered or unexported fields
}

Writer wraps an io.Writer to report write progress. This is useful for tracking upload progress.

func NewWriter

func NewWriter(w io.Writer, total int64, onUpdate Callback) *Writer

NewWriter creates a progress writer wrapping the given writer. total is the expected total bytes (use -1 if unknown). onUpdate is called after each Write with current and total bytes.

func (*Writer) BytesWritten

func (pw *Writer) BytesWritten() int64

BytesWritten returns the total bytes written so far.

func (*Writer) Write

func (pw *Writer) Write(p []byte) (int, error)

Write implements io.Writer, tracking bytes written and calling the progress callback.

Jump to

Keyboard shortcuts

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