How to make go build work with nested directories
<p>In the process of learning go I was playing around with making my own libraries. Here is what I did: in my $GOPATH/src I have two folders: <code>mylibs</code> and <code>test</code>. The <code>test</code> folder has a file called <code>test.go</code> which contains</p>

<pre><code>package test

import "mylibs/hi/saysHi"

func main() {
    saysHi.SayHi()
}
</code></pre>

<p>The <code>mylibs</code> folder contains another folder called <code>hi</code>, which has a file called <code>saysHi.go</code> containing:</p>

<pre><code>package saysHi

import "fmt"

func SayHi() {
    fmt.Printf("Hi\n")
}
</code></pre>

<p>So the directory structure looks like this:</p>

<ul>
<li>GOPATH/src</li>
<li><ul>
<li>test</li>
</ul></li>
<li><ul>
<li><ul>
<li>test.go</li>
</ul></li>
</ul></li>
<li><ul>
<li>mylibs</li>
</ul></li>
<li><ul>
<li><ul>
<li>hi</li>
</ul></li>
</ul></li>
<li><ul>
<li><ul>
<li><ul>
<li>saysHi.go</li>
</ul></li>
</ul></li>
</ul></li>
</ul>

<p>The problem is that when I try to compile <code>test</code> it complains saying</p>

<pre><code>cannot find package "mylibs/hi/saysHi" in any of: 
    [...]
    $GOPATH/src/mylibs/hi/saysHi (from $GOPATH)
</code></pre>

<p>I have deliberately made the directory structure deeper than necessary. If I make a simpler directory structure where I place <code>saysHi.go</code> in <code>$GOPATH/saysHi/saysHi.go</code> then it works.</p>

<p>But I don't see a reason for why this wouldn't work. Any ideas?</p>