Documentation
¶
Index ¶
- Variables
- func Download(dl *DownloadTask, timeout time.Duration) (err error)
- func DownloadWithContext(ctx context.Context, dl *DownloadTask) (err error)
- func Get(url string) (io.ReadCloser, error)
- func HTTPGet(url string) (body []byte, err error)
- func Headers(url string) (http.Header, error)
- func NewClient(baseURL string) *resty.Client
- func Size(url string) (int, error)
- type DownloadTask
- type DownloadTasks
- type GetDownload
- type HTTPClient
Constants ¶
This section is empty.
Variables ¶
View Source
var (
// UserAgent UserAgent
UserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36"
)
Functions ¶
func DownloadWithContext ¶
func DownloadWithContext(ctx context.Context, dl *DownloadTask) (err error)
Types ¶
type DownloadTask ¶
func NewDownloadTask ¶
func NewDownloadTask(link, path string) *DownloadTask
type DownloadTasks ¶
type DownloadTasks struct {
// contains filtered or unexported fields
}
func Batch ¶
func Batch(tasks *DownloadTasks, concurrent int, eachTimeout time.Duration) *DownloadTasks
func NewDownloadTasks ¶
func NewDownloadTasks() *DownloadTasks
func (*DownloadTasks) Add ¶
func (d *DownloadTasks) Add(link, path string)
func (*DownloadTasks) ForEach ¶
func (d *DownloadTasks) ForEach(f func(t *DownloadTask))
type GetDownload ¶
type GetDownload struct { OnEachStart func(t *DownloadTask) OnEachStop func(t *DownloadTask) OnEachSkip func(t *DownloadTask) Header http.Header Client http.Client }
func Default ¶
func Default() (g GetDownload)
func (*GetDownload) Batch ¶
func (g *GetDownload) Batch(tasks *DownloadTasks, concurrent int, eachTimeout time.Duration) *DownloadTasks
func (*GetDownload) Download ¶
func (g *GetDownload) Download(task *DownloadTask, timeout time.Duration) (err error)
func (*GetDownload) DownloadWithContext ¶
func (g *GetDownload) DownloadWithContext(ctx context.Context, task *DownloadTask) (err error)
Click to show internal directories.
Click to hide internal directories.