for _, p := range pkgs {
if p.Target == "" && (!p.Standard || p.ImportPath != "unsafe") {
- if p.ConflictDir != "" {
+ if p.cmdline {
+ errorf("go install: no install location for .go files listed on command line (GOBIN not set)")
+ } else if p.ConflictDir != "" {
errorf("go install: no install location for %s: hidden by %s", p.Dir, p.ConflictDir)
} else {
errorf("go install: no install location for directory %s outside GOPATH", p.Dir)
bp, err := ctxt.ImportDir(dir, 0)
pkg := new(Package)
pkg.local = true
+ pkg.cmdline = true
pkg.load(&stk, bp, err)
pkg.localPrefix = dirToImportPath(dir)
pkg.ImportPath = "command-line-arguments"
fake bool // synthesized package
forceBuild bool // this package must be rebuilt
forceLibrary bool // this package is a library (even if named "main")
+ cmdline bool // defined by files listed on command line
local bool // imported via local path (./ or ../)
localPrefix string // interpret ./ and ../ imports relative to this prefix
exeName string // desired name for temporary executable
# Without $GOBIN set, installing a program outside $GOPATH should fail
# (there is nowhere to install it).
-TEST install without destination
-if ./testgo install testdata/src/go-cmd-test/helloworld.go; then
+TEST install without destination fails
+if ./testgo install testdata/src/go-cmd-test/helloworld.go 2>testdata/err; then
echo "go install testdata/src/go-cmd-test/helloworld.go should have failed, did not"
ok=false
+elif ! grep 'no install location for .go files listed on command line' testdata/err; then
+ echo "wrong error:"
+ cat testdata/err
+ ok=false
fi
+rm -f testdata/err
# With $GOBIN set, should install there.
TEST install to GOBIN '(command-line package)'