Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DefaultProgress ¶
type DefaultProgress struct {
// contains filtered or unexported fields
}
DefaultProgress just shows the progress as a percentage.
func (*DefaultProgress) SetTotalBytes ¶ added in v0.0.2
func (dp *DefaultProgress) SetTotalBytes(totalBytes int64)
SetTotalBytes sets the total number of bytes to be downloaded.
type Downloader ¶
type Downloader struct {
// contains filtered or unexported fields
}
Downloader represents a downloader that can download files from a URL, and verify the checksum of the downloaded file.
func New ¶
func New( dlDir string, httpClient *http.Client, fsys fs.FS, hasher Hasher, progressWriter ProgressWriter, verifier HashVerifier, ) (*Downloader, error)
New returns a new Downloader.
type HashVerifier ¶
type HashVerifier interface { // Verify ensure the checksum of the given io.Reader // matches the given hash. Verify(in io.Reader, want string) error }
HashVerifier is an interface to verify a file's checksum.
type Hasher ¶
type Hasher interface { // Hash returns the checksum at the given path. // path can be a local file containing the checksum // or a remote URL to download the checksum from. Hash(ctx context.Context, path string) (string, error) }
Hasher is an interface to retrieve a file's checksum.
type ProgressBar ¶ added in v0.0.2
type ProgressBar struct {
*progressbar.ProgressBar
}
func (*ProgressBar) SetTotalBytes ¶ added in v0.0.2
func (pb *ProgressBar) SetTotalBytes(totalBytes int64)
type ProgressWriter ¶ added in v0.0.2
type ProgressWriter interface { io.Writer // Progress reports the progress of a download. SetTotalBytes(totalBytes int64) }
Progresser is an interface to report the progress of a download.
Click to show internal directories.
Click to hide internal directories.