diff options
author | Steve Manuel <nilslice@gmail.com> | 2017-03-01 11:33:33 -0800 |
---|---|---|
committer | Steve Manuel <nilslice@gmail.com> | 2017-03-01 11:33:33 -0800 |
commit | ad6220d2459e30569827b67e13921b0cd6257447 (patch) | |
tree | 4cfb0cd20661b7bdd3f84e402097bed544172c66 /cmd/ponzu/options.go | |
parent | d7f88d95435e1ffd216bc9b73f7d548cdb554982 (diff) |
replace GOPATH env var lookups with getGOPATH func throughout codebase
Diffstat (limited to 'cmd/ponzu/options.go')
-rw-r--r-- | cmd/ponzu/options.go | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/cmd/ponzu/options.go b/cmd/ponzu/options.go index c406975..77e842c 100644 --- a/cmd/ponzu/options.go +++ b/cmd/ponzu/options.go @@ -14,11 +14,14 @@ import ( func newProjectInDir(path string) error { // set path to be nested inside $GOPATH/src - gopath := os.Getenv("GOPATH") + gopath, err := getGOPATH() + if err != nil { + return err + } path = filepath.Join(gopath, "src", path) // check if anything exists at the path, ask if it should be overwritten - if _, err := os.Stat(path); !os.IsNotExist(err) { + if _, err = os.Stat(path); !os.IsNotExist(err) { fmt.Println("Path exists, overwrite contents? (y/N):") answer, err := getAnswer() @@ -67,7 +70,10 @@ func getAnswer() (string, error) { } func createProjectInDir(path string) error { - gopath := os.Getenv("GOPATH") + gopath, err := getGOPATH() + if err != nil { + return err + } repo := ponzuRepo local := filepath.Join(gopath, "src", filepath.Join(repo...)) network := "https://" + strings.Join(repo, "/") + ".git" @@ -76,7 +82,7 @@ func createProjectInDir(path string) error { } // create the directory or overwrite it - err := os.MkdirAll(path, os.ModeDir|os.ModePerm) + err = os.MkdirAll(path, os.ModeDir|os.ModePerm) if err != nil { return err } |