nali/pkg/download/download.go
zu1k 2f1d16408c fix: common download save to file
Signed-off-by: zu1k <i@zu1k.com>
2022-07-04 22:01:03 +08:00

24 lines
490 B
Go

package download
import (
"log"
"github.com/zu1k/nali/pkg/common"
)
func Download(filePath string, urls ...string) (data []byte, err error) {
_ = urls[0]
data, err = common.GetHttpClient().Get(urls...)
if err != nil {
log.Printf("文件下载失败,请手动下载解压后保存到本地: %s \n", filePath)
log.Println("下载链接:", urls)
return
}
if err := common.SaveFile(filePath, data); err == nil {
log.Println("文件下载成功:", filePath)
}
return
}