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
+9.6k Golang : Validate IPv6 example
+11.2k Google Maps URL parameters configuration
+10.4k Golang : Meaning of omitempty in struct's field tag
+19.2k Golang : Check if directory exist and create if does not exist
+6k PHP : How to check if an array is empty ?
+6.7k Golang : Check if password length meet the requirement
+35.1k Golang : Upload and download file to/from AWS S3
+14.8k Golang : Find commonalities in two slices or arrays example
+8.2k Golang : Get final or effective URL with Request.URL example
+5.4k Golang : Intercept, inject and replay HTTP traffics from web server
+5.6k Unix/Linux : How to find out the hard disk size?
+6k PageSpeed : Clear or flush cache on web server