Documentation ¶
Overview ¶
Package download provides a library for interruptable, resumable download acceleration with automatic Accept-Ranges support.
see all examples https://github.com/admpub/go-download/tree/master/examples
package main import ( "log" download "github.com/admpub/go-download" ) func main() { // no options specified so will default to 10 concurrent download by default f, err := download.Open("https://storage.googleapis.com/golang/go1.8.1.src.tar.gz", nil) if err != nil { log.Fatal(err) } defer f.Close() // f implements io.Reader, write file somewhere or do some other sort of work with it }
Index ¶
Constants ¶
const (
MB = 1024 * 1024
)
Variables ¶
var (
ErrMaximumSizeExceeded = errors.New("Maximum size exceeded")
)
Functions ¶
Types ¶
type Canceled ¶
type Canceled struct {
// contains filtered or unexported fields
}
Canceled is the error containing the cancelled error information
type ClientFn ¶ added in v1.0.1
ClientFn allows for a custom http.Client to be used for the http request
type ConcurrencyFn ¶
ConcurrencyFn is the function used to determine the level of concurrency aka the number of goroutines to use. Default concurrency level is 10
if returned value is < 1 then the default value will be used
type DeadlineExceeded ¶
type DeadlineExceeded struct {
// contains filtered or unexported fields
}
DeadlineExceeded is the error containing the deadline exceeded error information
func (*DeadlineExceeded) Error ¶
func (e *DeadlineExceeded) Error() string
Error returns the DeadlineExceeded error string
type File ¶
File represents an open file descriptor to a downloaded file(s)
func OpenContext ¶
OpenContext downloads and opens the file(s) downloaded by the given url and is cancellable using the provided context. The context provided must be non-nil
type InvalidResponseCode ¶
type InvalidResponseCode struct {
// contains filtered or unexported fields
}
InvalidResponseCode is the error containing the invalid response code error information
func (*InvalidResponseCode) Error ¶
func (e *InvalidResponseCode) Error() string
Error returns the InvalidResponseCode error string
type Options ¶
type Options struct { Concurrency ConcurrencyFn Proxy ProxyFn Client ClientFn Request RequestFn MaxSize int64 }
Options contains any specific configuration values for downloading/opening a file