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
+36k Golang : Get file last modified date and time
+8.5k PHP : How to parse ElasticSearch JSON ?
+7.3k Golang : Fixing Gorilla mux http.FileServer() 404 problem
+5.3k Golang : How to deal with configuration data?
+18.8k Golang : Implement getters and setters
+10.5k Golang : Create matrix with Gonum Matrix package example
+6.9k Mac OSX : Find large files by size
+10.6k Android Studio : Simple input textbox and intercept key example
+39.6k Golang : Remove dashes(or any character) from string
+9.6k Golang : Read file with ioutil
+15.4k Golang : Find location by IP address and display with Google Map
+7.9k Golang : Get today's weekday name and calculate target day distance example