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
+12.8k Golang : How to check if a file is hidden?
+6.3k Golang : Accessing dataframe-go element by row, column and name example
+8.3k Golang : Detect Pascal, Kebab, Screaming Snake and Camel cases
+9.2k Golang : Random Rune generator
+6.1k Golang : How to call function inside template with template.FuncMap
+6k Golang : Find the shortest line of text example
+6.3k Golang : Check if one string(rune) is permutation of another string(rune)
+8.1k Golang : What is the default port number for connecting to MySQL/MariaDB database ?
+9.6k Golang : Underscore string example
+13.1k Golang : Check if a file exist or not
+19.5k Golang : Saving private and public key to files