summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve <nilslice@gmail.com>2017-03-01 13:50:24 -0800
committerGitHub <noreply@github.com>2017-03-01 13:50:24 -0800
commit720367f1ea0cb391af196745aaf1f91bd11869a7 (patch)
tree990f5ac01a97426775233fbec87fd4f2e6e83981
parentad6220d2459e30569827b67e13921b0cd6257447 (diff)
parenta19b16e6e5fb8015869dbf7176fc6d3fa96f858e (diff)
Merge pull request #91 from Sirikon/ponzu-dev
Move getGOPATH method to paths.go
-rw-r--r--cmd/ponzu/add.go27
-rw-r--r--cmd/ponzu/paths.go33
2 files changed, 32 insertions, 28 deletions
diff --git a/cmd/ponzu/add.go b/cmd/ponzu/add.go
index abac59c..05d6f16 100644
--- a/cmd/ponzu/add.go
+++ b/cmd/ponzu/add.go
@@ -6,9 +6,7 @@ import (
"io"
"os"
"os/exec"
- "os/user"
"path/filepath"
- "runtime"
"strings"
)
@@ -60,31 +58,6 @@ func getAddon(args []string) error {
return nil
}
-// 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
-}
-
// this is distinct from copyAll() in that files are copied, not moved,
// since we also need them to remain in $GOPATH/src
// thanks to @markc of stack overflow for the copyFile and copyFileContents functions
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
+}