Documentation
¶
Overview ¶
Package download provides file download functionality with resume capability, concurrent downloads, and progress tracking.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Download ¶
Download downloads a file from the given URL and saves it to the specified destination. Uses a simple writer for output.
Parameters: - destination: the path where the downloaded file will be saved. - url: the URL of the file to download. - writer: writer for progress output (can be nil)
func WithResume ¶
func WithResume(ctx context.Context, destination, uri string, maxRetries int, writer io.Writer) error
WithResume downloads a file with resume capability and retry logic. It extends the basic Download function with the ability to resume interrupted downloads.
Parameters: - ctx: context for cancellation. - destination: the path where the downloaded file will be saved. - uri: the URL of the file to download. - maxRetries: maximum number of retry attempts (0 = no retries, default: 3). - writer: writer for progress output (can be nil)
func WithResumeContext ¶
func WithResumeContext( destination, uri string, maxRetries int, packageName, sourceName string, writer io.Writer, ) error
WithResumeContext downloads a file with context information for enhanced progress reporting.
Parameters:
- destination: local file path where the downloaded content will be saved.
- uri: source URL to download from.
- maxRetries: maximum number of retry attempts (0 = no retries, default: 3).
- packageName: package name for progress reporting (if empty, uses logger component or "yap").
- sourceName: source name for progress reporting (if empty, uses filename from URI).
- writer: writer for progress output (can be nil)
Types ¶
type ProgressBar ¶
type ProgressBar struct {
// contains filtered or unexported fields
}
ProgressBar renders a single-line in-place progress bar to stderr. It uses only stdlib — no external dependencies.
func NewProgressBar ¶
func NewProgressBar(writer io.Writer, packageName, title string, total int64) *ProgressBar
NewProgressBar creates a progress bar whose prefix matches the yap log line format so it blends into the surrounding output.
func (*ProgressBar) Finish ¶
func (pb *ProgressBar) Finish()
Finish marks the bar complete, prints a final newline, and logs completion.
func (*ProgressBar) Update ¶
func (pb *ProgressBar) Update(current int64)
Update sets the current byte count and redraws the bar if enough has changed.