Golang io/ioutil.TempDir() function example
package io/ioutil
Golang io/ioutil.TempDir() function usage example
package main
import (
"fmt"
"io/ioutil"
)
func main() {
dir := "./"
prefix := "new"
name, err := ioutil.TempDir(dir, prefix)
if err != nil {
fmt.Println(err)
}
// TempDir will create "new" directory
// and you need to capture the name of the temp directory
// to remove it later
fmt.Printf("%s \n", name)
}
Reference :
Advertisement
Something interesting
Tutorials
+6.2k Golang & Javascript : How to save cropped image to file on server
+11.7k Golang : How to detect a server/machine network interface capabilities?
+11.3k Golang : Post data with url.Values{}
+27.6k PHP : Convert(cast) string to bigInt
+14.2k Golang : Chunk split or divide a string into smaller chunk example
+41.9k Golang : How do I convert int to uint8?
+41k Golang : How to check if a string contains another sub-string?
+33k Golang : How to check if a date is within certain range?
+14.9k Golang : How to check for empty array string or string?
+13.9k Golang : Get current time
+8.5k Android Studio : Import third-party library or package into Gradle Scripts