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
+22.3k Golang : Storing cookies in http.CookieJar example
+2.1k Java : Get FX sentiment from website example
+17.9k Golang : Convert seconds to minutes and remainder seconds
+5.5k Javascript : Put image into Chrome browser's console
+5.4k Golang : Of hash table and hash map
+19.2k Golang : How to run Golang application such as web server in the background or as daemon?
+11k Golang : error parsing regexp: invalid or unsupported Perl syntax
+4.1k Golang : Get S3 or CloudFront object or file information
+11.2k Golang : How to login and logout with JWT example
+2.9k Linux : How to set root password in Linux Mint
+3.8k Golang : How to search a list of records or data structures