mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2026-02-13 02:30:26 +00:00
✏️ 分离 data
This commit is contained in:
22
utils/dl/dl.go
Normal file
22
utils/dl/dl.go
Normal file
@@ -0,0 +1,22 @@
|
||||
// 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
|
||||
}
|
||||
Reference in New Issue
Block a user