<p>I've tried Go before (<code>1.4</code>) but I got frustrated over dependency management so I stopped. Now I'm relearning Go, I installed the latest Go version (<code>1.7.1</code>) using <a href="https://github.com/moovweb/gvm" rel="nofollow">gvm</a> and I am looking to build a simple rest api app using <a href="https://github.com/gin-gonic/gin" rel="nofollow">gin</a>. I installed it using <code>glide get https://github.com/gin-gonic/gin</code> (<a href="https://glide.sh/" rel="nofollow">glide</a>) and that created a "vendor" folder on my project root. Running my app though, <code>go run main.go</code>, I encounter this error</p>
<pre><code>main.go:3:8: cannot find package "github.com/gin-gonic/gin" in any of:
/home/yowmamasita/.gvm/gos/go1.6.3/src/github.com/gin-gonic/gin (from $GOROOT)
/home/yowmamasita/.gvm/pkgsets/go1.6.3/global/src/github.com/gin-gonic/gin (from $GOPATH)
</code></pre>
<p>It is not resolving the "vendor" directory glide just created</p>
<pre><code>.
├── glide.lock
├── glide.yaml
├── main.go
├── README.md
└── vendor
└── github.com
└── gin-gonic
└── gin
</code></pre>
<p>Not sure what's happening here, I thought after 1.5, it should be able to resolve imports from "vendor" directories without doing anything. I even added my projects folder on my <code>$GOPATH</code></p>
<p><code>/home/yowmamasita/.gvm/pkgsets/go1.7.1/global:/home/yowmamasita/goprojects</code></p>
<p>What am I doing wrong here? I tried 1.6.3 too and I get the same error.</p>
<hr/>**评论:**<br/><br/>ChristophBerger: <pre><p>Why do you use <code>gvm</code>? Did the <a href="https://golang.org/doc/go1compat" rel="nofollow">Go 1 compatibility promise</a> not work out for you?</p>
<p>I am asking because there seems to be a mismatch between the go version you use and the directories that <code>go run</code> searches for packages. I know you said you also tested with Go 1.6.3 but TBH a tool that messes with GOROOT and GOPATH is always a bit suspicious to me. </p>
<p>To track down the issue,</p>
<ul>
<li>Does the output of <code>go env</code> look ok?<br/></li>
<li>Does the glide yml file look ok?</li>
<li>What happens if you get <code>gin</code> the classic way via <code>go get</code> (and try <code>go run</code> again)?</li>
<li>What happens if you move the glide files (yml and lock) and the vendor dir to a safe location, then start over by going through the steps <a href="/u/philoserf" rel="nofollow">/u/philoserf</a> suggested (<code>glide init</code>, <code>glide up</code>), and finally do <code>glide get</code> again?</li>
</ul></pre>yowmamasita: <pre><blockquote>
<p>Why do you use <code>gvm</code>? Did the <a href="https://golang.org/doc/go1compat" rel="nofollow">Go 1 compatibility promise</a> not work out for you?</p>
</blockquote>
<p>I used <code>gvm</code> because it's easier to just use this to update go whenever a new version is out.</p>
<blockquote>
<p>Does the output of <code>go env</code> look ok? </p>
</blockquote>
<p><code>go env</code> and <code>go version</code> output: <a href="https://ghostbin.com/paste/ayebv" rel="nofollow">https://ghostbin.com/paste/ayebv</a></p>
<blockquote>
<p>Does the glide yml file look ok?</p>
</blockquote>
<p>not sure what you mean by "okay" but here's my glide.yaml: <a href="https://ghostbin.com/paste/3zsd2" rel="nofollow">https://ghostbin.com/paste/3zsd2</a></p>
<blockquote>
<p>What happens if you get <code>gin</code> the classic way via <code>go get</code> (and try <code>go run</code> again)?</p>
</blockquote>
<p>it works (the package is installed in <code>/home/yowmamasita/.gvm/pkgsets/go1.7.1/global/src/github.com/gin-gonic/gin</code>)</p>
<blockquote>
<p>What happens if you move the glide files (yml and lock) and the vendor dir to a safe location, then start over by going through the steps <a href="/u/philoserf" rel="nofollow">/u/philoserf</a> suggested (<code>glide init</code>, <code>glide up</code>), and finally do <code>glide get</code> again?</p>
</blockquote>
<p>Doesn't work again (removed gin installed globally)</p></pre>ChristophBerger: <pre><p>In the glide yaml file, the line <code>package: .</code> looks suspicious to me. I would have expected a <a href="https://glide.readthedocs.io/en/latest/glide.yaml/" rel="nofollow">path relative to $GOPATH/src</a> instead of the dot. Where is your main project located? It should reside in a folder beneath <code>$GOPATH/src</code>.</p></pre>yowmamasita: <pre><p>I think that's it. I don't have it under <code>$GOPATH/src</code>. It's just in my <code>$HOME/projects</code>. What should I put in my glide.yaml file? Or is it moving my project folder that is the proper way?</p>
<p>Big thanks btw</p></pre>ChristophBerger: <pre><p>You need to move the project folder to $GOPATH/src. The Go tools are pretty strict about the location of source files. </p></pre>kaneshin: <pre><p>I use <a href="https://github.com/kaneshin/goenv" rel="nofollow">goenv</a> instead of gvm to manage the versions of golang.</p></pre>yowmamasita: <pre><p>will give this a try now, looks great as this doesn't modify my GOPATH as <a href="/u/ChristophBerger" rel="nofollow">/u/ChristophBerger</a> has pointed out with <code>gvm</code></p></pre>shovelpost: <pre><blockquote>
<p>Now I'm relearning Go</p>
</blockquote>
<p>If you are relearning Go then I'd recommend this time to learn to do the procedure yourself.</p>
<p>To update to a new version you delete the old folder, download the new version, unzip it and copy it to the old location. On Windows the procedure is even simpler.</p>
<p>Now unfortunately we do not have a community blessed vendor tool yet. My personal recommendation is <a href="https://github.com/FiloSottile/gvt" rel="nofollow">gvt</a>. It's so simple it hurts.</p>
<p>Still I would recommend before using a tool, to do the vendoring procedure a few times by hand to get a better feel of how things work.</p></pre>forgiv: <pre><p>The problem is that the go run command checks for the project to be in the Go src directory. Personally I hate using that directory, but if you don't mind not being able to use go run or go install, the go build command works in any directory.</p></pre>ghazninattarshah: <pre><p>I encountered same issue, that when you do go build, it doesn't detect the vendor directory created by glide. </p></pre>philoserf: <pre><p>Why use <code>glide</code> and <code>gvm</code>? One vendor manager at a time please.</p>
<p>Glide will do it all. <code>glide init</code>, answer the questions, <code>glide up</code>.</p>
<p>Off to the races.</p></pre>yowmamasita: <pre><p>Only used <code>gvm</code> to install go, it's not a package manager like <code>glide</code>. It's a version manager <a href="https://github.com/moovweb/gvm" rel="nofollow">https://github.com/moovweb/gvm</a></p></pre>
![](https://static.golangjob.cn/static/img/banner.png)