Fix the issue on windows by replace defer io.Close() with mannual call it

This commit is contained in:
2017-06-28 15:36:13 +08:00
parent d7e8fa127f
commit 3d04f93c10
+7 -9
View File
@@ -149,9 +149,9 @@ Fetch:
if err != nil {
log.Fatal("Create file failed:" + err.Error())
}
defer out.Close()
io.Copy(out, response.Body)
io.Copy(out, response.Body)
out.Close()
speak()
}
@@ -163,13 +163,11 @@ func speak() {
}
return
}
command := exec.Command("cmdmp3", getAudioFilePath())
out, _ := command.Output()
log.Error(string(out))
command.Start()
// if err := command.Run(); err != nil {
// log.Error("Failed to say the words: " + err.Error())
// }
command := exec.Command("cmdmp3.exe", getAudioFilePath())
if err := command.Run(); err != nil {
log.Error("Failed to say the words: " + err.Error())
}
}