FAQ
Reviewers: golang-dev1,

Message:
Hello golang-dev@googlegroups.com,

I'd like you to review this change to
https://code.google.com/p/go/


Description:
cmd/go: fix error for 'go install x.go' when GOBIN is not set

Fixes issue 6191.
Fixes issue 5426.

Please review this at https://codereview.appspot.com/13234052/

Affected files (+12, -3 lines):
    M src/cmd/go/build.go
    M src/cmd/go/pkg.go
    M src/cmd/go/test.bash


Index: src/cmd/go/build.go
===================================================================
--- a/src/cmd/go/build.go
+++ b/src/cmd/go/build.go
@@ -311,7 +311,9 @@

    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)
@@ -486,6 +488,7 @@
    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"
Index: src/cmd/go/pkg.go
===================================================================
--- a/src/cmd/go/pkg.go
+++ b/src/cmd/go/pkg.go
@@ -82,6 +82,7 @@
    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
Index: src/cmd/go/test.bash
===================================================================
--- a/src/cmd/go/test.bash
+++ b/src/cmd/go/test.bash
@@ -150,11 +150,16 @@

   # 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)'


--

---
You received this message because you are subscribed to the Google Groups "golang-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Bradfitz at Sep 10, 2013 at 5:55 pm
    LGTM


    https://codereview.appspot.com/13234052/

    --

    ---
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Rsc at Sep 10, 2013 at 6:41 pm
    *** Submitted as
    https://code.google.com/p/go/source/detail?r=8ef79645ac2e ***

    cmd/go: fix error for 'go install x.go' when GOBIN is not set

    Fixes issue 6191.
    Fixes issue 5426.

    R=golang-dev, bradfitz
    CC=golang-dev
    https://codereview.appspot.com/13234052


    https://codereview.appspot.com/13234052/

    --

    ---
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-dev @
categoriesgo
postedSep 10, '13 at 5:43p
activeSep 10, '13 at 6:41p
posts3
users2
websitegolang.org

2 users in discussion

Rsc: 2 posts Bradfitz: 1 post

People

Translate

site design / logo © 2022 Grokbase