cmd: Make more accurate error when there is no $GOPATH

This commit is contained in:
Albert Nigmatzianov 2017-05-15 09:20:36 +02:00
parent fa9ac853ce
commit e9078fccb8
1 changed files with 3 additions and 4 deletions

View File

@ -27,13 +27,12 @@ var cmdDirs = [...]string{"cmd", "cmds", "command", "commands"}
var srcPaths []string var srcPaths []string
func init() { func init() {
// Initialize goPaths and srcPaths // Initialize srcPaths.
envGoPath := os.Getenv("GOPATH") envGoPath := os.Getenv("GOPATH")
if envGoPath == "" { goPaths := filepath.SplitList(envGoPath)
if len(goPaths) == 0 {
er("$GOPATH is not set") er("$GOPATH is not set")
} }
goPaths := filepath.SplitList(envGoPath)
srcPaths = make([]string, 0, len(goPaths)) srcPaths = make([]string, 0, len(goPaths))
for _, goPath := range goPaths { for _, goPath := range goPaths {
srcPaths = append(srcPaths, filepath.Join(goPath, "src")) srcPaths = append(srcPaths, filepath.Join(goPath, "src"))