Export $HOME lookup to pkg/homedir

Signed-off-by: Ahmet Alp Balkan <ahmetb@microsoft.com>
This commit is contained in:
Ahmet Alp Balkan 2015-02-06 10:18:49 -08:00
parent 193aa34569
commit 2c44d13150
3 changed files with 34 additions and 0 deletions

16
homedir/homedir.go Normal file
View file

@ -0,0 +1,16 @@
package homedir
import (
"os"
"runtime"
)
// Get returns the home directory of the current user with the help of
// environment variables depending on the target operating system.
// Returned path should be used with "path/filepath" to form new paths.
func Get() string {
if runtime.GOOS == "windows" {
return os.Getenv("USERPROFILE")
}
return os.Getenv("HOME")
}