mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 22:00:11 +08:00
23 lines
319 B
Go
23 lines
319 B
Go
// Package dl 下载实用工具
|
|
package dl
|
|
|
|
import (
|
|
"io"
|
|
"net/http"
|
|
"os"
|
|
)
|
|
|
|
func DownloadTo(url, file string) error {
|
|
resp, err := http.Get(url)
|
|
if err == nil {
|
|
var f *os.File
|
|
f, err = os.Create(file)
|
|
if err == nil {
|
|
_, err = io.Copy(f, resp.Body)
|
|
resp.Body.Close()
|
|
f.Close()
|
|
}
|
|
}
|
|
return err
|
|
}
|