File tree 3 files changed +12
-3
lines changed 3 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -311,7 +311,9 @@ func runInstall(cmd *Command, args []string) {
311
311
312
312
for _ , p := range pkgs {
313
313
if p .Target == "" && (! p .Standard || p .ImportPath != "unsafe" ) {
314
- if p .ConflictDir != "" {
314
+ if p .cmdline {
315
+ errorf ("go install: no install location for .go files listed on command line (GOBIN not set)" )
316
+ } else if p .ConflictDir != "" {
315
317
errorf ("go install: no install location for %s: hidden by %s" , p .Dir , p .ConflictDir )
316
318
} else {
317
319
errorf ("go install: no install location for directory %s outside GOPATH" , p .Dir )
@@ -486,6 +488,7 @@ func goFilesPackage(gofiles []string) *Package {
486
488
bp , err := ctxt .ImportDir (dir , 0 )
487
489
pkg := new (Package )
488
490
pkg .local = true
491
+ pkg .cmdline = true
489
492
pkg .load (& stk , bp , err )
490
493
pkg .localPrefix = dirToImportPath (dir )
491
494
pkg .ImportPath = "command-line-arguments"
Original file line number Diff line number Diff line change @@ -82,6 +82,7 @@ type Package struct {
82
82
fake bool // synthesized package
83
83
forceBuild bool // this package must be rebuilt
84
84
forceLibrary bool // this package is a library (even if named "main")
85
+ cmdline bool // defined by files listed on command line
85
86
local bool // imported via local path (./ or ../)
86
87
localPrefix string // interpret ./ and ../ imports relative to this prefix
87
88
exeName string // desired name for temporary executable
Original file line number Diff line number Diff line change 150
150
151
151
# Without $GOBIN set, installing a program outside $GOPATH should fail
152
152
# (there is nowhere to install it).
153
- TEST install without destination
154
- if ./testgo install testdata/src/go-cmd-test/helloworld.go; then
153
+ TEST install without destination fails
154
+ if ./testgo install testdata/src/go-cmd-test/helloworld.go 2> testdata/err ; then
155
155
echo " go install testdata/src/go-cmd-test/helloworld.go should have failed, did not"
156
156
ok=false
157
+ elif ! grep ' no install location for .go files listed on command line' testdata/err; then
158
+ echo " wrong error:"
159
+ cat testdata/err
160
+ ok=false
157
161
fi
162
+ rm -f testdata/err
158
163
159
164
# With $GOBIN set, should install there.
160
165
TEST install to GOBIN ' (command-line package)'
You can’t perform that action at this time.
0 commit comments