文件创建错误时打印错误内容

This commit is contained in:
suguo.yao 2021-09-03 22:36:12 +08:00
parent fa15f852fd
commit 43232d9661
1 changed files with 2 additions and 2 deletions

View File

@ -79,7 +79,7 @@ func downloadFile(client http.Client, path, filename string, wg *sync.WaitGroup)
// 创建文件
file, err := os.Create(filepath.Join(path, filename))
if err != nil {
fmt.Printf("create file: %s error\n", filename)
fmt.Printf("create file %s error: %s\n", filename, err.Error())
return
}
defer file.Close()
@ -91,7 +91,7 @@ func downloadFile(client http.Client, path, filename string, wg *sync.WaitGroup)
file.Write(buff[:n])
break
}
fmt.Println("error: ", err)
fmt.Println("error: ", err.Error())
os.Remove(filepath.Join(path, filename))
return
}