Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
// DownloadingFileSuffix 断点续传临时文件后缀
DownloadingFileSuffix = ".baidupcs_go_downloading"
)
View Source
var ( // FileNameRE 正则表达式: 匹配文件名 FileNameRE = regexp.MustCompile("filename=\"(.*?)\"") )
Functions ¶
func DoDownload ¶
DoDownload 简单网络下载器, 使用默认下载线程, 通过调用 SetMaxThread 来修改默认下载线程
Types ¶
type Block ¶
type Block struct { Begin int64 `json:"begin"` End int64 `json:"end"` Final bool `json:"isfinal"` // 最后线程, 因为最后的下载线程, 需要另外做处理 // contains filtered or unexported fields }
Block 下载区块
type DownloadStatus ¶
type DownloadStatus struct { Downloaded int64 `json:"downloaded"` Speeds int64 MaxSpeeds int64 // contains filtered or unexported fields }
DownloadStatus 状态
type Downloader ¶
type Downloader struct { URL string // 下载地址 Size int64 // 文件大小 File *os.File // 要写入的文件 BlockList blockList // 用于记录未下载的文件块起始位置 // contains filtered or unexported fields }
Downloader 下载详情
func NewDownloader ¶
func NewDownloader(url, savePath string, h *requester.HTTPClient) (der *Downloader, err error)
NewDownloader 创建新的文件下载
func (*Downloader) GetStatusChan ¶
func (der *Downloader) GetStatusChan() <-chan DownloadStatus
GetStatusChan 返回 DownloadStatus 对象的 channel
func (*Downloader) OnError ¶
func (der *Downloader) OnError(fn func(int, error))
OnError 任务出错时触发的事件
errCode为错误码,errStr为错误描述
Click to show internal directories.
Click to hide internal directories.