From e9078fccb8b1e6914310b96d5e1be43713f3a372 Mon Sep 17 00:00:00 2001 From: Albert Nigmatzianov Date: Mon, 15 May 2017 09:20:36 +0200 Subject: [PATCH] cmd: Make more accurate error when there is no $GOPATH --- cobra/cmd/helpers.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/cobra/cmd/helpers.go b/cobra/cmd/helpers.go index a53ab2ef..6114227d 100644 --- a/cobra/cmd/helpers.go +++ b/cobra/cmd/helpers.go @@ -27,13 +27,12 @@ var cmdDirs = [...]string{"cmd", "cmds", "command", "commands"} var srcPaths []string func init() { - // Initialize goPaths and srcPaths + // Initialize srcPaths. envGoPath := os.Getenv("GOPATH") - if envGoPath == "" { + goPaths := filepath.SplitList(envGoPath) + if len(goPaths) == 0 { er("$GOPATH is not set") } - - goPaths := filepath.SplitList(envGoPath) srcPaths = make([]string, 0, len(goPaths)) for _, goPath := range goPaths { srcPaths = append(srcPaths, filepath.Join(goPath, "src"))