Golang TempDir,TempFile作成する
main.go
package main
import (
"fmt"
"io/ioutil"
"os"
)
func main() {
dir, _ := ioutil.TempDir("", "aaa")
fmt.Println(dir)
fp, _ := ioutil.TempFile(dir, "xxx")
fpath := fp.Name()
fmt.Println(fpath)
fp2, _ := ioutil.TempFile(dir, "yyy")
fpath2 := fp2.Name()
fmt.Println(fpath2)
fp.Close()
fp2.Close()
os.RemoveAll(dir)
}
//C:\Users\####\AppData\Local\Temp\aaa661041139
//C:\Users\####\AppData\Local\Temp\aaa661041139\xxx642705078
//C:\Users\####\AppData\Local\Temp\aaa661041139\yyy013873821