文件创建错误时打印错误内容
This commit is contained in:
parent
fa15f852fd
commit
43232d9661
4
main.go
4
main.go
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue