diff options
author | Niall Sheridan <nsheridan@gmail.com> | 2018-08-23 22:51:21 +0100 |
---|---|---|
committer | Niall Sheridan <nsheridan@gmail.com> | 2018-08-24 13:45:03 +0100 |
commit | f8e3dea19012ccf05965d10255789eec33c2ebcf (patch) | |
tree | 8522ceada8bc7270648f29615b89550db910cb6c /vendor/github.com/gobuffalo/packr/env.go | |
parent | 91f9bc722152146466523861162b85195f99875b (diff) |
Update deps
Diffstat (limited to 'vendor/github.com/gobuffalo/packr/env.go')
-rw-r--r-- | vendor/github.com/gobuffalo/packr/env.go | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/vendor/github.com/gobuffalo/packr/env.go b/vendor/github.com/gobuffalo/packr/env.go index 2c744e7..c52e73a 100644 --- a/vendor/github.com/gobuffalo/packr/env.go +++ b/vendor/github.com/gobuffalo/packr/env.go @@ -1,19 +1,31 @@ package packr import ( - "go/build" "os" + "os/exec" + "path/filepath" "strings" + "sync" ) +var goPath = filepath.Join(os.Getenv("HOME"), "go") + +func init() { + var once sync.Once + once.Do(func() { + cmd := exec.Command("go", "env", "GOPATH") + b, err := cmd.CombinedOutput() + if err != nil { + return + } + goPath = strings.TrimSpace(string(b)) + }) +} + // GoPath returns the current GOPATH env var // or if it's missing, the default. func GoPath() string { - go_path := strings.Split(os.Getenv("GOPATH"), string(os.PathListSeparator)) - if len(go_path) == 0 || go_path[0] == "" { - return build.Default.GOPATH - } - return go_path[0] + return goPath } // GoBin returns the current GO_BIN env var |