diff options
author | Ollie Phillips <oliver@eantics.co.uk> | 2017-02-24 17:28:02 +0000 |
---|---|---|
committer | Ollie Phillips <oliver@eantics.co.uk> | 2017-02-24 17:28:02 +0000 |
commit | cdc044e28529aa129de7ef685089a7dcc4f1d511 (patch) | |
tree | 225325edac262c69e19e91ba13200b4795c2aff1 /cmd/ponzu/add.go | |
parent | 522eab3f9ba4297cf44685cf5e79902b90833845 (diff) |
break GOPATH determination out into separate function
Diffstat (limited to 'cmd/ponzu/add.go')
-rw-r--r-- | cmd/ponzu/add.go | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/cmd/ponzu/add.go b/cmd/ponzu/add.go index d0569c0..5d443b7 100644 --- a/cmd/ponzu/add.go +++ b/cmd/ponzu/add.go @@ -39,14 +39,10 @@ func getAddon(args []string) error { // Copy to ./addons folder // GOPATH can be a list delimited by ":" on Linux or ";" on Windows // `go get` uses the first, this should parse out the first whatever the OS - envGOPATH := os.Getenv("GOPATH") - gopaths := strings.Split(envGOPATH, ":") - gopath := gopaths[0] - gopaths = strings.Split(envGOPATH, ";") - gopath = gopaths[0] + gopath := resolveGOPATH() src := filepath.Join(gopath, addonPath) - dest := filepath.Join("./addons", addonPath) + dest := filepath.Join("addons", addonPath) err = copyAll(src, dest) if err != nil { @@ -54,3 +50,16 @@ func getAddon(args []string) error { } return nil } + +// GOPATH can be a list delimited by ":" on Linux or ";" on Windows +// `go get` uses saves packages to the first entry, so this function +// should parse out the first whatever the OS +func resolveGOPATH() string { + + envGOPATH := os.Getenv("GOPATH") + gopaths := strings.Split(envGOPATH, ":") + gopath := gopaths[0] + gopaths = strings.Split(envGOPATH, ";") + gopath = gopaths[0] + return gopath +} |