downloader

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 20, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UnsetHTTPProxy added in v0.2.0

func UnsetHTTPProxy()

Types

type ClientConfig added in v0.2.0

type ClientConfig struct {
	HTTPClient *http.Client
}
var Config ClientConfig

type Section

type Section struct {
	Start    int64
	End      int64
	Filename string
}

Section is a part of a downloading task. It will be downloaded to the disk with its filename.

type Task

type Task struct {
	URL      string
	Folder   string
	FileName string
	Size     int64
	Sections []Section
}

Task is a downloading task which contains multiple downloading sections.

func NewTask

func NewTask(url string, folder string, workerNum int) (*Task, error)

NewTask create a new task according to the given url, worker number and path name. If the workerNum given is non-positive, it will set the number of the system's logical cpu as the worker number.

func (*Task) Run

func (t *Task) Run() error

Run starts the task. It will download each sections to disk and merge them.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL