Documentation
¶
Index ¶
Constants ¶
View Source
const MAX_CONCURRENT_DOWNLOADS = 6
Variables ¶
View Source
var ErrNotCached = errors.New("data not cached and request failed")
Functions ¶
func CheckResponse ¶
CheckResponse ensures the status code of an HTTP response is successful, returning an HTTPStatusError if not.
func DownloadFile ¶
func DownloadFile(entry DownloadEntry) error
DownloadFile downloads the specified DownloadEntry and saves it.
All parent directories are created in order to create the file.
func StartDownloadEntries ¶
func StartDownloadEntries(entries []DownloadEntry) chan error
StartDownloadEntries runs DownloadFile on each specified DownloadEntry and returns a channel with the download results.
Types ¶
type Cache ¶ added in v1.1.0
type Cache[T any] struct { Path string URL string RemoteSha1 string AlwaysFetch bool Unmarshaler func(data []byte, v any) error // Custom unmarshal function. Defaults to JSON. }
A Cache stores and retrieves remote data to unmarshal either into JSON or a custom unmarshaler.
type DownloadEntry ¶
type HTTPStatusError ¶ added in v1.1.0
HTTPStatusError is an error type returned when an HTTP response finishes with a status code >= 300 or < 200
func (*HTTPStatusError) Error ¶ added in v1.1.0
func (e *HTTPStatusError) Error() string
Click to show internal directories.
Click to hide internal directories.