Golang os.TempDir() function example

package os

Golang os.TempDir() function usage example. Use this function to find out the directory to store your temporary files such as uploaded files.

 package main

 import (
 "fmt"
 "os"
 )

 func main() {

 tmp := os.TempDir()

 fmt.Println("The default directory use for temporary files on this server is : ", tmp)
 }

Sample output :

The default directory use for temporary files on this server is : /tmp

Reference :

http://golang.org/pkg/os/#TempDir

Advertisement