--help, -h show help (default: false)
关于 cli 这个库的运用,可以参阅官方文档,写的很详细,也有很多例子。
反省能否支持并发下载创立另外一个文件 downloader.go,定义一个结构体 Dowloader:
package main
type Downloader struct {
concurrency int
}
func NewDownloader(concurrency int) *Downloader {
return &Downloader{concurrency: concurrency}
}
为该结构体添加 Download 办法:
func (d *Downloader) Download(strURL, filename string) error {
if filename == "" {
filename = path.Base(strURL)
}
resp, err := http.Head(strURL)
if err != nil {
return err
}
(责任编辑:admin)