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
+6.9k Web : How to see your website from different countries?
+11.5k Golang : Calculations using complex numbers example
+13.3k Golang : How to get year, month and day?
+27.5k PHP : Count number of JSON items/objects
+10k Golang : Find and replace data in all files recursively
+12.9k Golang : List objects in AWS S3 bucket
+7.1k Golang : Of hash table and hash map
+13.7k Golang : Get dimension(width and height) of image file
+5k Golang : Issue HTTP commands to server and port example
+7.7k Golang : Scan files for certain pattern and rename part of the files
+7.3k Golang : Get YouTube playlist
+8.1k Golang : Add build version and other information in executables