summaryrefslogtreecommitdiff
path: root/cmd/ponzu/paths.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/ponzu/paths.go')
-rw-r--r--cmd/ponzu/paths.go33
1 files changed, 32 insertions, 1 deletions
diff --git a/cmd/ponzu/paths.go b/cmd/ponzu/paths.go
index 8bc6e39..8d5407f 100644
--- a/cmd/ponzu/paths.go
+++ b/cmd/ponzu/paths.go
@@ -1,6 +1,12 @@
package main
-import "runtime"
+import (
+ "os"
+ "os/user"
+ "path/filepath"
+ "runtime"
+ "strings"
+)
// buildOutputName returns the correct ponzu-server file name
// based on the host Operating System
@@ -11,3 +17,28 @@ func buildOutputName() string {
return "ponzu-server"
}
+
+// resolve GOPATH. In 1.8 can be default, or custom. A custom GOPATH can
+// also contain multiple paths, in which case 'go get' uses the first
+func getGOPATH() (string, error) {
+ var gopath string
+ gopath = os.Getenv("GOPATH")
+ if gopath == "" {
+ // not set, find the default
+ usr, err := user.Current()
+ if err != nil {
+ return gopath, err
+ }
+ gopath = filepath.Join(usr.HomeDir, "go")
+ } else {
+ // parse out in case of multiple, retain first
+ if runtime.GOOS == "windows" {
+ gopaths := strings.Split(gopath, ";")
+ gopath = gopaths[0]
+ } else {
+ gopaths := strings.Split(gopath, ":")
+ gopath = gopaths[0]
+ }
+ }
+ return gopath, nil
+}