summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/spf13/cobra/cobra/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/spf13/cobra/cobra/cmd')
-rw-r--r--vendor/github.com/spf13/cobra/cobra/cmd/helpers.go23
-rw-r--r--vendor/github.com/spf13/cobra/cobra/cmd/licenses.go2
2 files changed, 23 insertions, 2 deletions
diff --git a/vendor/github.com/spf13/cobra/cobra/cmd/helpers.go b/vendor/github.com/spf13/cobra/cobra/cmd/helpers.go
index c5e261ce3..e5b37ec72 100644
--- a/vendor/github.com/spf13/cobra/cobra/cmd/helpers.go
+++ b/vendor/github.com/spf13/cobra/cobra/cmd/helpers.go
@@ -18,6 +18,7 @@ import (
"fmt"
"io"
"os"
+ "os/exec"
"path/filepath"
"strings"
"text/template"
@@ -31,7 +32,27 @@ func init() {
envGoPath := os.Getenv("GOPATH")
goPaths := filepath.SplitList(envGoPath)
if len(goPaths) == 0 {
- er("$GOPATH is not set")
+ // Adapted from https://github.com/Masterminds/glide/pull/798/files.
+ // As of Go 1.8 the GOPATH is no longer required to be set. Instead there
+ // is a default value. If there is no GOPATH check for the default value.
+ // Note, checking the GOPATH first to avoid invoking the go toolchain if
+ // possible.
+
+ goExecutable := os.Getenv("COBRA_GO_EXECUTABLE")
+ if len(goExecutable) <= 0 {
+ goExecutable = "go"
+ }
+
+ out, err := exec.Command(goExecutable, "env", "GOPATH").Output()
+ if err != nil {
+ er(err)
+ }
+
+ toolchainGoPath := strings.TrimSpace(string(out))
+ goPaths = filepath.SplitList(toolchainGoPath)
+ if len(goPaths) == 0 {
+ er("$GOPATH is not set")
+ }
}
srcPaths = make([]string, 0, len(goPaths))
for _, goPath := range goPaths {
diff --git a/vendor/github.com/spf13/cobra/cobra/cmd/licenses.go b/vendor/github.com/spf13/cobra/cobra/cmd/licenses.go
index cf2a6b7af..a070134dd 100644
--- a/vendor/github.com/spf13/cobra/cobra/cmd/licenses.go
+++ b/vendor/github.com/spf13/cobra/cobra/cmd/licenses.go
@@ -63,7 +63,7 @@ func getLicense() License {
// If user wants to have custom license, use that.
if viper.IsSet("license.header") || viper.IsSet("license.text") {
return License{Header: viper.GetString("license.header"),
- Text: "license.text"}
+ Text: viper.GetString("license.text")}
}
// If user wants to have built-in license, use that.