Secure temporary file: Difference between revisions

→‎{{header|Go}}: Expand example to a run-able program that shows the file name and removes it
(new Emacs Lisp)
(→‎{{header|Go}}: Expand example to a run-able program that shows the file name and removes it)
Line 127:
 
=={{header|Go}}==
<lang go>importpackage "io/ioutil"main
 
import (
file_obj, err := ioutil.TempFile("", "foo")</lang>
"fmt"
"io/ioutil"
"log"
"os"
)
 
func main() {
file_obj f, err := ioutil.TempFile("", "foo")</lang>
if err != nil {
log.Fatal(err)
}
// Make sure we remove the file once we're done.
defer os.Remove(f.Name())
 
// … use the file via 'f' …
fmt.Println("Using temporary file:", f.Name())
}</lang>
{{out}}
<pre>
Using temporary file: /tmp/foo054003078
</pre>
 
=={{header|Groovy}}==
Anonymous user