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
+11.1k Golang : Display list of countries and ISO codes
+9.1k Golang : Wait and sync.WaitGroup example
+5.7k PHP : Shuffle to display different content or advertisement
+6.7k Gogland : Where to put source code files in package directory for rookie
+18k Golang : How to run your code only once with sync.Once object
+7.9k Golang : How to extract video or image files from html source code
+5.3k Golang : Map within a map example
+10.5k Golang : Convert decimal number(integer) to IPv4 address
+9.8k Golang : Web routing/multiplex example
+6.1k Golang : Array mapping with Interface
+6.9k Golang : Get final or effective URL with Request.URL example
+18.3k Swift : Convert (cast) Int to int32 or Uint32