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.1k Golang : automatically figure out array length(size) with three dots
+3.9k Golang : Detect face in uploaded photo like GPlus
+8.6k Golang : Clean formatting/indenting or pretty print JSON result
+3.3k Javascript : Shuffle or randomize array example
+17.4k Golang : untar or extract tar ball archive example
+20.4k Golang : Strings to lowercase and uppercase example
+4.4k Golang : Oanda bot with Telegram and RSI example
+2.9k Golang : A program that contain another program and executes it during run-time
+9.4k Golang : Extract part of string with regular expression
+3.8k List of Golang XML tutorials
+4.8k Golang : Levenshtein distance example