Commit 2ff3e9c8 authored by Russ Cox's avatar Russ Cox

cmd/go: do not print "go install" in errors from other commands

Fixes #20251.

Change-Id: I312a9534248668c8b3b4cf979591ed1a49e509e1
Reviewed-on: https://go-review.googlesource.com/75474
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarDavid Crawshaw <crawshaw@golang.org>
parent f2503e61
...@@ -38,6 +38,8 @@ var ( ...@@ -38,6 +38,8 @@ var (
BuildWork bool // -work flag BuildWork bool // -work flag
BuildX bool // -x flag BuildX bool // -x flag
CmdName string // "build", "install", "list", etc.
DebugActiongraph string // -debug-actiongraph flag (undocumented, unstable) DebugActiongraph string // -debug-actiongraph flag (undocumented, unstable)
) )
......
...@@ -550,14 +550,14 @@ func InstallPackages(args []string, forGet bool) { ...@@ -550,14 +550,14 @@ func InstallPackages(args []string, forGet bool) {
if p.Target == "" && (!p.Standard || p.ImportPath != "unsafe") { if p.Target == "" && (!p.Standard || p.ImportPath != "unsafe") {
switch { switch {
case p.Internal.GobinSubdir: case p.Internal.GobinSubdir:
base.Errorf("go install: cannot install cross-compiled binaries when GOBIN is set") base.Errorf("go %s: cannot install cross-compiled binaries when GOBIN is set", cfg.CmdName)
case p.Internal.Cmdline: case p.Internal.Cmdline:
base.Errorf("go install: no install location for .go files listed on command line (GOBIN not set)") base.Errorf("go %s: no install location for .go files listed on command line (GOBIN not set)", cfg.CmdName)
case p.ConflictDir != "": case p.ConflictDir != "":
base.Errorf("go install: no install location for %s: hidden by %s", p.Dir, p.ConflictDir) base.Errorf("go %s: no install location for %s: hidden by %s", cfg.CmdName, p.Dir, p.ConflictDir)
default: default:
base.Errorf("go install: no install location for directory %s outside GOPATH\n"+ base.Errorf("go %s: no install location for directory %s outside GOPATH\n"+
"\tFor more details see: 'go help gopath'", p.Dir) "\tFor more details see: 'go help gopath'", cfg.CmdName, p.Dir)
} }
} }
} }
......
...@@ -945,7 +945,7 @@ func BuildInstallFunc(b *Builder, a *Action) (err error) { ...@@ -945,7 +945,7 @@ func BuildInstallFunc(b *Builder, a *Action) (err error) {
if a.Package != nil { if a.Package != nil {
sep, path = " ", a.Package.ImportPath sep, path = " ", a.Package.ImportPath
} }
err = fmt.Errorf("go install%s%s: %v", sep, path, err) err = fmt.Errorf("go %s%s%s: %v", cfg.CmdName, sep, path, err)
} }
}() }()
......
...@@ -77,6 +77,7 @@ func main() { ...@@ -77,6 +77,7 @@ func main() {
base.Usage() base.Usage()
} }
cfg.CmdName = args[0] // for error messages
if args[0] == "help" { if args[0] == "help" {
help.Help(args[1:]) help.Help(args[1:])
return return
......
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