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
+3.8k JavaScript : Rounding number to decimal formats to display currency
+10.7k Linux : How to install driver for 600Mbps Dual Band Wifi USB Adapter
+23.5k Golang : Change file read or write permission example
+4.3k Golang : Qt update UI elements with core.QCoreApplication_ProcessEvents
+7.8k Golang : Accept any number of function arguments with three dots(...)
+8k Golang : Intercept and compare HTTP response code example
+7.1k Findstr command the Grep equivalent for Windows
+17.8k Golang : Delete duplicate items from a slice/array
+7.3k How to show different content from website server when AdBlock is detected?
+5.1k Golang : Calculate US Dollar Index (DXY)
+4.5k Golang : Frobnicate or tweaking a string example
+7.9k Golang : Capture text return from exec function example