gocross-platformtempdirsystem-paths

Get system folder paths in Go?


Is it possible to get the path of system folders in Go, in a cross-platform way? eg. temp folders, "document" folders, etc.

I found ioutil.TempFolder/File but they do something different. Any idea?


Solution

  • There's currently no way to access standard system folders in a cross-platform way. The Home directory though can be access using the user package:

    u, _ := user.Current()
    fmt.Println(u.HomeDir)