progress

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrintProgressBar

func PrintProgressBar(f io.Writer, msg string, done uint64, total uint64, final bool)

PrintProgressBar prints a nice progress bar.

Types

type ProgressOption

type ProgressOption func(*ProgressWriter)

ProgressOption configures the behaviour of ProgressWriter.

func WithFrequency

func WithFrequency(freq time.Duration) ProgressOption

WithFrequency sets how often updates are printed.

func WithMessage

func WithMessage(msg string) ProgressOption

WithMessage sets the status prefix shown before percentage/KiB.

func WithOutput

func WithOutput(w io.Writer) ProgressOption

WithOutput sets the destination writer (defaults to os.Stderr).

type ProgressWriter

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

ProgressWriter is an io.Writer that prints a simple progress bar. It is safe to use with io.TeeReader.

pw := common.NewProgressWriter(resp.ContentLength, common.WithMessage("Downloading..."))
io.Copy(dst, io.TeeReader(src, pw))

func NewProgressWriter

func NewProgressWriter(contentLen int64, opts ...ProgressOption) *ProgressWriter

NewProgressWriter returns a configured ProgressWriter.

func (*ProgressWriter) Write

func (p *ProgressWriter) Write(b []byte) (int, error)

Write implements io.Writer.

Jump to

Keyboard shortcuts

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