Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // MkdirAll is used to create all intermediate directories if required. MkdirAll = Mkdirs(newBool(true)) // MkdirNone is used to create no intermediate directories. MkdirNone = Mkdirs(newBool(false)) )
Functions ¶
func FromURL ¶
FromURL downloads the specified `src` URL to `w` writer using the specified `Options`.
func ToFile ¶
func ToFile(src, dest string, options FileOptions) error
ToFile downloads the specified `src` URL to `dest` file using the specified `FileOptions`.
Types ¶
type FileOptions ¶
type FileOptions struct { // Options is the common set of downloader options. Options // Mkdirs is the option to create parent directories of target directory if they don't // exist. Use `download.MkdirAll` or `download.MkdirNone` (or any `*bool`). Defaults to // `download.MkdirAll`. Mkdirs Mkdirs }
FileOptions holds the possible configuration options to download to a file.
type Mkdirs ¶
type Mkdirs *bool
Mkdirs is a custom type so we can differentiate between not specified (nil) and set.
type Options ¶
type Options struct { // HTTPClient is an optional client to perform downloads with. If nil, `http.DefaultClient` // will be used. HTTPClient *http.Client // Checksum is either a checksum string, or a URL or path to a file containing the checksum. The file // can either contain the checksum only or contain multiple lines of the format: // CHECKSUM FILENAME Checksum string // Checksum hash is the hash for the checksum. Currently only supports SHA1, SHA256, SHA512 and MD5. // If unspecified, defaults to SHA256. ChecksumHash crypto.Hash // ProgressBars is the configuration of progress bars output. Set to `nil` (default) to disable. ProgressBars *ProgressBarOptions // Retries is the number of retries for retriable errors. Defaults to 5 if unset. Set to -1 for // infinite retries. Retries int // RetryInterval is the interval between retries. RetryInterval time.Duration }
Options holds the possible configuration options for the Downloader.
type ProgressBarOptions ¶
type ProgressBarOptions struct { // Writer holds where to output the progress bars to. Defaults to `os.Stdout`. Writer io.Writer // Width is the maximum width of the progress bar. If output to a narrower terminal then this // will be ignored. MaxWidth int }
ProgressBarOptions holds the configuration for progress bars if required.
Click to show internal directories.
Click to hide internal directories.