1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Golang TempDir,TempFile作成

Posted at

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


1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?