]> Cypherpunks repositories - gostls13.git/commitdiff
go/build: allow ~ in middle of path, just not at beginning
authorJonathan Nieder <jrn@google.com>
Fri, 15 Mar 2013 03:59:49 +0000 (23:59 -0400)
committerRuss Cox <rsc@golang.org>
Fri, 15 Mar 2013 03:59:49 +0000 (23:59 -0400)
CL 7799045 relaxed the restriction in cmd/go on ~ in GOPATH
to allow paths with ~ in the middle while continuing to
protect against the common mistake of using GOPATH='~/home'
instead of GOPATH=~/home.  Unfortunately go/build still
filters these paths out:

        $ GOPATH=/tmp/test~ing go build
        test.go:22:2: cannot find package "test" in any of:
                /usr/lib/go/test (from $GOROOT)
                ($GOPATH not set)

So relax the requirement in go/build, too.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7826043

src/pkg/go/build/build.go

index d0e420f4339601923a314d5312d1ab5d6f845572..d5f181d7c1e97cd80972a52a756813188d2d9fe5 100644 (file)
@@ -212,8 +212,8 @@ func (ctxt *Context) gopath() []string {
                        // Do not get confused by this common mistake.
                        continue
                }
-               if strings.Contains(p, "~") && runtime.GOOS != "windows" {
-                       // Path segments containing ~ on Unix are almost always
+               if strings.HasPrefix(p, "~") {
+                       // Path segments starting with ~ on Unix are almost always
                        // users who have incorrectly quoted ~ while setting GOPATH,
                        // preventing it from expanding to $HOME.
                        // The situation is made more confusing by the fact that