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
+5.5k PHP : Fix Call to undefined function curl_init() error
+16.3k Golang : How to implement two-factor authentication?
+17.8k Golang : Login and logout a user after password verification and redirect example
+43.2k Golang : Get hardware information such as disk, memory and CPU usage
+9.9k Golang : Ordinal and Ordinalize a given number to the English ordinal numeral
+7.3k Linux : How to fix Brother HL-1110 printing blank page problem
+10.9k Golang : Create S3 bucket with official aws-sdk-go package
+6.7k Golang : Output or print out JSON stream/encoded data
+15.2k Golang : Get all local users and print out their home directory, description and group id
+7.2k Golang : Not able to grep log.Println() output
+87.2k Golang : How to convert character to ASCII and back
+6k Golang : Build new URL for named or registered route with Gorilla webtoolkit example