use cross-compile compatible home dir detection

Signed-off-by: Matt Drollette <matt@drollette.com>
This commit is contained in:
Matt Drollette 2015-01-22 09:36:36 -06:00
parent 29bbf0fb27
commit a66abedab5
1 changed files with 6 additions and 10 deletions

View File

@ -1,21 +1,17 @@
package main package main
import ( import (
"os"
"os/user"
"path"
"github.com/codegangsta/cli" "github.com/codegangsta/cli"
"os"
log "github.com/Sirupsen/logrus" "path/filepath"
"runtime"
) )
func homepath(p string) string { func homepath(p string) string {
usr, err := user.Current() if runtime.GOOS == "windows" {
if err != nil { return filepath.Join(os.Getenv("USERPROFILE"), p)
log.Fatal(err)
} }
return path.Join(usr.HomeDir, p) return filepath.Join(os.Getenv("HOME"), p)
} }
func getDiscovery(c *cli.Context) string { func getDiscovery(c *cli.Context) string {