Avoid panic after connection failure

Download function, when client.Do returns err= Nil, return false after printing the error message to avoid panic
This commit is contained in:
秋来冬风
2023-03-19 13:04:07 +08:00
parent d09c77bac8
commit a2cea8fd91

View File

@@ -107,6 +107,7 @@ func Download(url string, target string, version string) bool {
response, err := client.Do(req)
if err != nil {
fmt.Println("Error while downloading", url, "-", err)
return false
}
defer response.Body.Close()
c := make(chan os.Signal, 2)