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
import (
"os"
"os/user"
"path"
"github.com/codegangsta/cli"
log "github.com/Sirupsen/logrus"
"os"
"path/filepath"
"runtime"
)
func homepath(p string) string {
usr, err := user.Current()
if err != nil {
log.Fatal(err)
if runtime.GOOS == "windows" {
return filepath.Join(os.Getenv("USERPROFILE"), p)
}
return path.Join(usr.HomeDir, p)
return filepath.Join(os.Getenv("HOME"), p)
}
func getDiscovery(c *cli.Context) string {