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
+7.8k Golang : Get today's weekday name and calculate target day distance example
+6k Golang : Build new URL for named or registered route with Gorilla webtoolkit example
+6.7k Golang : Output or print out JSON stream/encoded data
+13.4k Golang : Get constant name from value
+12.4k Elastic Search : Return all records (higher than default 10)
+13.8k Golang : unknown escape sequence error
+11.6k Golang : Surveillance with web camera and OpenCV
+21.8k Golang : Use TLS version 1.2 and enforce server security configuration over client
+15.6k Golang : ROT47 (Caesar cipher by 47 characters) example
+20.1k Golang : Count number of digits from given integer value
+15.8k Golang : Get digits from integer before and after given position example