feat: 新增双端安装卸载 安卓清楚缓存

This commit is contained in:
余泓铮
2024-08-06 20:30:18 +08:00
parent 7c1b5ce57e
commit c8a42e951a
11 changed files with 236 additions and 47 deletions

View File

@@ -8,9 +8,11 @@ import (
"encoding/csv"
builtinJSON "encoding/json"
"fmt"
"io"
"math"
"math/rand"
"net"
"net/http"
"os"
"path/filepath"
"reflect"
@@ -509,3 +511,29 @@ func GetCurrentDay() string {
formattedDate := now.Format("20060102")
return formattedDate
}
func DownloadFile(filePath string, url string) error {
log.Info().Str("filePath", filePath).Str("url", url).Msg("download file")
out, err := os.Create(filePath)
if err != nil {
return err
}
defer out.Close()
resp, err := http.Get(url)
if err != nil {
return err
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return fmt.Errorf("bad status: %s, download failed", resp.Status)
}
_, err = io.Copy(out, resp.Body)
if err != nil {
return err
}
return nil
}