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
+5k Golang : Compound interest over time example
+26.8k Golang : Connect to database (MySQL/MariaDB) server
+15.4k CodeIgniter/PHP : Create directory if does not exist example
+7.8k Golang : Apply Histogram Equalization to color images
+11.3k Golang : Covert map/slice/array to JSON or XML format
+5.1k PHP : How to check if an array is empty ?
+5k Golang : Extract unicode string from another unicode string example
+10.3k Golang : Generate DSA private, public key and PEM files example
+6.8k Android Studio : Rating bar example
+33.5k Golang : Upload and download file to/from AWS S3
+12.8k Elastic Search : Mapping date format and sort by date
+8.2k Golang : How to get ECDSA curve and parameters data?