✏️ 分离 data

This commit is contained in:
fumiama
2021-10-14 23:07:13 +08:00
parent 98b21d0fdf
commit bdffbfab67
8 changed files with 24 additions and 20 deletions

22
utils/dl/dl.go Normal file
View 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
}