Documentation
¶
Overview ¶
Package filecache downloads and verifies cached files.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Download ¶
func Download(ctx context.Context, url string, path string, algo string, checksum string, opts DownloadOptions) (string, error)
Download downloads a file from a url to a path and verifies its checksum using the specified algorithm ("sha256" or "sha512"). If checksum is empty, the file is written without verification.
func Exists ¶
Exists checks if a file already exists at a path and verifies its checksum using the specified algorithm ("sha256" or "sha512").
func ResolveCACert ¶
ResolveCACert turns a CA Cert spec into an absolute path on disk. The spec may be an inline PEM, an http(s) URL, or a filesystem path. Inline PEMs and URL responses are cached under cacheDir.
Types ¶
type DownloadOptions ¶
DownloadOptions controls how a file download is performed.
type Progress ¶
type Progress struct {
Writer io.Writer
Total int64 // response "Content-Length" header
Current int64
LastTime time.Time
Interval time.Duration
ProgressFunc func(current, total int64)
}
Progress is a wrapper for an io.Writer that reports progress for a file download