mirror of
https://github.com/wahyd4/say-it.git
synced 2026-08-08 21:02:13 +10:00
Fix the issue of can't create folder on Mac
This commit is contained in:
@@ -26,6 +26,7 @@ import (
|
||||
|
||||
const (
|
||||
MP3FileName = "/tmp/say-it.mp3"
|
||||
AudioFileFolder = "/tmp"
|
||||
WindowsMP3FileName = "\\say-it.mp3"
|
||||
)
|
||||
|
||||
@@ -145,6 +146,10 @@ Fetch:
|
||||
log.Fatalf("Get voice failed, error code is: %d, error message is %s", errorResp.Code, errorResp.Message)
|
||||
}
|
||||
|
||||
if err = os.MkdirAll(getAudioFolder(), os.ModePerm); err != nil {
|
||||
log.Fatal("Can't create temporary folder:" + getAudioFolder())
|
||||
}
|
||||
|
||||
out, err := os.Create(getAudioFilePath())
|
||||
if err != nil {
|
||||
log.Fatal("Create file failed:" + err.Error())
|
||||
@@ -194,3 +199,10 @@ func getAudioFilePath() string {
|
||||
}
|
||||
return utils.HomeDir() + WindowsMP3FileName
|
||||
}
|
||||
|
||||
func getAudioFolder() string {
|
||||
if runtime.GOOS == "darwin" {
|
||||
return utils.HomeDir() + AudioFileFolder
|
||||
}
|
||||
return utils.HomeDir()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user