Commit 4f4da07e authored by Egon Elbre's avatar Egon Elbre Committed by Russ Cox

cmd/go: suggest running 'go help gopath' with problematic GOPATH

Suggest running 'go help gopath' when the running 'go install .'
and the folder is outside of GOPATH.

Added link to 'https://golang.org/doc/code.html' in gopath help
for more information.

Example output:

% go install .
go install: no install location for directory f:\x\badmessage outside GOPATH
        please run 'go help gopath' for more information

% go help gopath
... SNIP ...
See https://golang.org/doc/code.html for an example.

Fixes #8457

Change-Id: I0ef6ee3c65bb12af2168eafeb757258aa3835664
Reviewed-on: https://go-review.googlesource.com/9258Reviewed-by: default avatarRuss Cox <rsc@golang.org>
parent 01187f75
...@@ -868,6 +868,8 @@ Go searches each directory listed in GOPATH to find source code, ...@@ -868,6 +868,8 @@ Go searches each directory listed in GOPATH to find source code,
but new packages are always downloaded into the first directory but new packages are always downloaded into the first directory
in the list. in the list.
See https://golang.org/doc/code.html for an example.
Import path syntax Import path syntax
......
...@@ -505,7 +505,8 @@ func runInstall(cmd *Command, args []string) { ...@@ -505,7 +505,8 @@ func runInstall(cmd *Command, args []string) {
} else if p.ConflictDir != "" { } else if p.ConflictDir != "" {
errorf("go install: no install location for %s: hidden by %s", p.Dir, p.ConflictDir) errorf("go install: no install location for %s: hidden by %s", p.Dir, p.ConflictDir)
} else { } else {
errorf("go install: no install location for directory %s outside GOPATH", p.Dir) errorf("go install: no install location for directory %s outside GOPATH\n"+
"\tFor more details see: go help gopath", p.Dir)
} }
} }
} }
......
...@@ -321,6 +321,8 @@ Here's an example directory layout: ...@@ -321,6 +321,8 @@ Here's an example directory layout:
Go searches each directory listed in GOPATH to find source code, Go searches each directory listed in GOPATH to find source code,
but new packages are always downloaded into the first directory but new packages are always downloaded into the first directory
in the list. in the list.
See https://golang.org/doc/code.html for an example.
`, `,
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment