Logo

Programming-Idioms

History of Idiom 138 > diff from v2 to v3

Edit summary for version 3 by programming-idioms.org:
[Go] +Demo

Version 2

2016-07-12, 14:36:32

Version 3

2016-07-12, 14:46:21

Idiom #138 Create temp file

Create a new temporary file on filesystem, for writing.

Idiom #138 Create temp file

Create a new temporary file on filesystem, for writing.

Imports
import "io/ioutil"
Imports
import "io/ioutil"
Code
tmpfile, err := ioutil.TempFile("", "")
Code
tmpfile, err := ioutil.TempFile("", "")
Comments bubble
tmpfile has type *os.File.

Use tmpfile.Name() if you need the pathname.
Comments bubble
tmpfile has type *os.File.

Use tmpfile.Name() if you need the pathname.
Doc URL
https://golang.org/pkg/io/ioutil/#TempFile
Doc URL
https://golang.org/pkg/io/ioutil/#TempFile
Demo URL
https://play.golang.org/p/CE0qLWoPL4