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
+4.2k Python : Convert(cast) string to bytes example
+15.1k Golang :Trim white spaces from a string
+6k Golang : Mapping Iban to Dunging alphabets
+11.4k Golang : HTTP response JSON encoded data
+6.1k Web : How to see your website from different countries?
+25.5k PHP : Convert(cast) string to bigInt
+10k Golang : How to use if, eq and print properly in html template
+5k Golang : Calculate US Dollar Index (DXY)
+4.3k Golang : Issue HTTP commands to server and port example
+11.4k Golang : Exit, terminating or aborting a program
+8.3k Golang : Find correlation coefficient example
+10k Golang : Characters limiter example