cmd/go-contrib-init: better GOPATH checkout error message
Modify the error message to provide more context if the user is in the wrong directory. (The default Terminal.app does not do a great job of showing what directory you are currently in). Change-Id: Iafcbbd2070ca968863120fb8c4bc15609475cda2 Reviewed-on: https://go-review.googlesource.com/48232 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
7a94893dc3
commit
6f1996fdfe
|
@ -147,16 +147,20 @@ func checkGoroot() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkWorkingDir() {
|
func checkWorkingDir() {
|
||||||
if *repo == "go" {
|
|
||||||
if inGoPath() {
|
|
||||||
log.Fatal("You can't work on Go from within your GOPATH. Please checkout Go outside of your GOPATH")
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
wd, err := os.Getwd()
|
wd, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
if *repo == "go" {
|
||||||
|
if inGoPath(wd) {
|
||||||
|
log.Fatalf(`You can't work on Go from within your GOPATH. Please checkout Go outside of your GOPATH
|
||||||
|
|
||||||
|
Current directory: %s
|
||||||
|
GOPATH: %s
|
||||||
|
`, wd, os.Getenv("GOPATH"))
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
gopath := firstGoPath()
|
gopath := firstGoPath()
|
||||||
if gopath == "" {
|
if gopath == "" {
|
||||||
|
@ -197,12 +201,7 @@ func exists(path string) (bool, error) {
|
||||||
return true, err
|
return true, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func inGoPath() bool {
|
func inGoPath(wd string) bool {
|
||||||
wd, err := os.Getwd()
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if os.Getenv("GOPATH") == "" {
|
if os.Getenv("GOPATH") == "" {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue