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
+14.9k Golang : Adding XML attributes to xml data or use attribute to differentiate a common tag name
+8.3k Golang : Find relative luminance or color brightness
+9.3k Golang : Generate random Chinese, Japanese, Korean and other runes
+5.8k Get website traffic ranking with Similar Web or Alexa
+19.9k Golang : Measure http.Get() execution time
+24k Golang : Fix type interface{} has no field or no methods and type assertions example
+4.1k Detect if Google Analytics and Developer Media are loaded properly or not
+5.8k Golang : Markov chains to predict probability of next state example
+17.5k Golang : Multi threading or run two processes or more example
+6.6k Golang : Combine slices of complex numbers and operation example
+13.5k Golang : Verify token from Google Authenticator App