<p dir="auto">This is using Go 1.6, but I don't think the behavior has changed recently.</p>
<p dir="auto"><code class="notranslate">go build</code> (and probably other go commands) normally take Go package names (that is, relative to some GOPATH component) but, as special cases, also take relative and absolute directories.</p>
<p dir="auto"><code class="notranslate">go help packages</code> says this:</p>
<blockquote>
<p dir="auto">An import path that is a rooted path or that begins with<br>
a . or .. element is interpreted as a file system path and<br>
denotes the package in that directory.</p>
</blockquote>
<p dir="auto">However, this does not fully describe the go tool's behavior when given relative paths such as <code class="notranslate">.</code> or <code class="notranslate">./hello</code>. I haven't looked into the code, but it seems like the tool tries to resolve such paths relative to GOPATH and does different things depending on what it finds.</p>
<p dir="auto">Here are two examples.</p>
<p dir="auto">First, there is a very different error given depending on whether the given path is inside a GOPATH or not:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ pwd
/tmp/build
$ ls
$ mkdir -p a/src b/src
$ cd a/src/
$ GOPATH=/asdf go build ./hello
can't load package: package ./hello: open /tmp/build/a/src/hello: no such file or directory
$ GOPATH=/tmp/build/a go build ./hello                                                                                                                                                                                              
can't load package: package hello: cannot find package &quot;hello&quot; in any of:
        /home/caleb/apps/go/src/hello (from $GOROOT)
        /tmp/build/a/src/hello (from $GOPATH)
"><pre class="notranslate"><code class="notranslate">$ pwd
/tmp/build
$ ls
$ mkdir -p a/src b/src
$ cd a/src/
$ GOPATH=/asdf go build ./hello
can't load package: package ./hello: open /tmp/build/a/src/hello: no such file or directory
$ GOPATH=/tmp/build/a go build ./hello                                                                                                                                                                                              
can't load package: package hello: cannot find package "hello" in any of:
        /home/caleb/apps/go/src/hello (from $GOROOT)
        /tmp/build/a/src/hello (from $GOPATH)

</code></pre></div>
<p dir="auto">There are actual behavior differences as well, though. For instance, you can build a package given a non-existent relative path if the resolved package name does exist in some other GOPATH component (or GOROOT, for that matter):</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ # continuing from above...
$ cd /tmp/build/b/src/
$ mkdir hello
$ cat &gt; hello/hello.go
package main
func main() { println(&quot;hello&quot;) }
$ cd /tmp/build/a/src/
$ ls
$ GOPATH=/asdf go build ./hello
can't load package: package ./hello: open /tmp/build/a/src/hello: no such file or directory
$ GOPATH=/tmp/build/a:/tmp/build/b go build ./hello
$ ./hello
hello"><pre class="notranslate"><code class="notranslate">$ # continuing from above...
$ cd /tmp/build/b/src/
$ mkdir hello
$ cat &gt; hello/hello.go
package main
func main() { println("hello") }
$ cd /tmp/build/a/src/
$ ls
$ GOPATH=/asdf go build ./hello
can't load package: package ./hello: open /tmp/build/a/src/hello: no such file or directory
$ GOPATH=/tmp/build/a:/tmp/build/b go build ./hello
$ ./hello
hello
</code></pre></div>
<p dir="auto">That seems to directly contradict "interpreted as a file system path" in the <code class="notranslate">go help packages</code> output.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="f$ pwd
/usr/local/google/home/rsc/src/code.google.com/p/rsc
f$ go install ./jfmt
can't load package: package code.google.com/p/rsc/jfmt: cannot find package &quot;code.google.com/p/rsc/jfmt&quot; in any of:
    /usr/local/google/home/rsc/go/src/code.google.com/p/rsc/jfmt (from $GOROOT)
    /usr/local/google/home/rsc/src/code.google.com/p/rsc/jfmt (from $GOPATH)
f$ "><pre class="notranslate"><code class="notranslate">f$ pwd
/usr/local/google/home/rsc/src/code.google.com/p/rsc
f$ go install ./jfmt
can't load package: package code.google.com/p/rsc/jfmt: cannot find package "code.google.com/p/rsc/jfmt" in any of:
    /usr/local/google/home/rsc/go/src/code.google.com/p/rsc/jfmt (from $GOROOT)
    /usr/local/google/home/rsc/src/code.google.com/p/rsc/jfmt (from $GOPATH)
f$ 
</code></pre></div>
<p dir="auto">There is no ./jfmt directory in this example. That should be the end. It should not figure out that I am in $GOPATH/src/code.google.com/p/rsc and go looking for code.google.com/p/rsc/jfmt in other work spaces.</p>