Documentation ¶
Overview ¶
Package download helps with download files and keeping track of where you have downloaded them. It's designed to be embedded in another struct. Composition ahoy!
Example ¶
package main import ( "fmt" download "github.com/codeclysm/downloader" ) func main() { img := struct { download.Resource Author string }{} img.Name = "Mona Lisa" img.Author = "Leonardo da Vinci" img.URL = "https://upload.wikimedia.org/wikipedia/commons/thumb/6/6a/Mona_Lisa.jpg/396px-Mona_Lisa.jpg" fmt.Println(img.Download("paintings", nil)) fmt.Println(img.Where()) }
Output: <nil> [paintings]
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Opts ¶
type Opts struct { // Client is the http client used to fetch the resource Client *http.Client // Cache is a flag that tells the Download func not to download twice the resource in the same location Cache bool // Sha256Sum is the sum that's used to check that the download was correct Sha256Sum string // Handler is the function that saves or extracts the resource downloaded Handler func(body io.Reader, name, location string) error }
Opts is a struct of options to be passed to the Download function
Click to show internal directories.
Click to hide internal directories.