summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Manuel <nilslice@gmail.com>2017-03-01 11:33:33 -0800
committerSteve Manuel <nilslice@gmail.com>2017-03-01 11:33:33 -0800
commitad6220d2459e30569827b67e13921b0cd6257447 (patch)
tree4cfb0cd20661b7bdd3f84e402097bed544172c66
parentd7f88d95435e1ffd216bc9b73f7d548cdb554982 (diff)
replace GOPATH env var lookups with getGOPATH func throughout codebase
-rw-r--r--cmd/ponzu/options.go14
-rw-r--r--cmd/ponzu/usage.go6
2 files changed, 14 insertions, 6 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
}
diff --git a/cmd/ponzu/usage.go b/cmd/ponzu/usage.go
index fd289cf..939b0c0 100644
--- a/cmd/ponzu/usage.go
+++ b/cmd/ponzu/usage.go
@@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"
"io/ioutil"
- "os"
"path/filepath"
"time"
)
@@ -180,7 +179,10 @@ func ponzu(isCLI bool) (map[string]interface{}, error) {
info := filepath.Join("cmd", "ponzu", "ponzu.json")
if isCLI {
- gopath := os.Getenv("GOPATH")
+ gopath, err := getGOPATH()
+ if err != nil {
+ return nil, err
+ }
repo := filepath.Join(gopath, "src", "github.com", "ponzu-cms", "ponzu")
info = filepath.Join(repo, "cmd", "ponzu", "ponzu.json")
}