Golang io/ioutil.TempFile() function example
package io/ioutil
Golang io/ioutil.TempFile() function usage example
package main
import (
"fmt"
"io/ioutil"
)
func main() {
dir := "./"
prefix := "tempFileName"
file, err := ioutil.TempFile(dir, prefix)
if err != nil {
fmt.Println(err)
}
// TempFile will create a "new" file
// and you need to capture the name of the temp file
// to remove it later
fmt.Printf("%s \n", file.Name())
}
Reference :
Advertisement
Something interesting
Tutorials
+12.7k Golang : zlib compress file example
+6.3k Golang : Detect face in uploaded photo like GPlus
+5.7k Golang : Frobnicate or tweaking a string example
+4.3k Javascript : How to show different content with noscript?
+5.4k Unix/Linux : How to archive and compress entire directory ?
+5.9k AWS S3 : Prevent Hotlinking policy
+6.3k Golang : Calculate US Dollar Index (DXY)
+21.2k Golang : Convert(cast) string to rune and back to string example
+26.4k Golang : Convert(cast) string to uint8 type and back to string
+18.5k Golang : Example for RSA package functions
+13.2k Golang : Convert(cast) int to int64