Anonymous user
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>
import (
file_obj, err := ioutil.TempFile("", "foo")</lang>▼
"fmt"
"io/ioutil"
"log"
"os"
)
func main() {
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}}==
|