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?
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)
A built-in option doesn't exist yet. Your best bet is to open an issue and submit a feature request.
In the meantime you can add support yourself by using platform specific +build flags. With that you have a couple of options:
It may also be helpful to read the source code of the os
package to see how platform-specific information is obtained. This could help you devise a way to get this information, and perhaps submit a patch to be included.
Besides the methods Luke mentioned, on Windows you can get some of the paths from environment variables. Same applies, to some extent, to Unix ($HOME, etc.).