Golang : Create Temporary File
Need to create a temporary file in Go? Easy. Below is the code in Go for creating a temporary file
package main
import (
"fmt"
"os"
"io/ioutil"
)
func main () {
file, err := ioutil.TempFile(os.TempDir(), "temp")
if err != nil {
panic(err)
}
fmt.Printf("Temp File created!")
defer os.Remove(file.Name())
}
Reference :
See also : Golang : Create File
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+17k Golang : Display list of time zones with GMT
+19.3k Golang : Saving private and public key to files
+23.5k Golang : Create PDF file from HTML file
+5.9k Golang : Pat multiplexer routing example
+8.9k Golang : Translate language with language package example
+14.3k Golang : Get checkbox or extract multipart form data value example
+2.7k Java : Get FX sentiment from website example
+22.2k Golang : Print out struct values in string format
+27.9k Golang : How to create new XML file ?
+19.9k Golang : For loop continue,break and range
+18.3k Golang : Measure http.Get() execution time
+11.9k Golang : Qt progress dialog example