<p>So I started using dep and I'm having a hard time setting my GOPATH to use the vendor folder.</p>
<p>At the top of my file I have:
<code>
GOPATH := ${PWD}/vendor:${GOPATH}
export GOPATH
</code></p>
<p>Then my build command is with <code>BINARY</code> being set:
<code>
go build -o ./bin/${BINARY}
</code></p>
<p>I'm getting errors that it can't find my source files that are in sub packages. Ex:</p>
<p><code>
application.go:5:2: cannot find package "github.com/Fill/project/githubclient" in any of:
/usr/local/Cellar/go/1.8.1/libexec/src/github.com/Fill/project/githubclient (from $GOROOT)
</code></p>
<p>Not sure how to solve this.</p>
<hr/>**评论:**<br/><br/>kemitche: <pre><p>Your GOPATH should just be <code>/usr/local/Cellar/go/1.8.1/libexec</code> it seems? The vendor dir gets picked up correctly without being added to your GOPATH, as long as your directories are set-up properly.</p></pre>n1ghtm4n: <pre><p>You don't have to set your <code>$GOPATH</code> to use <code>vendor/</code>. <code>go build</code> will search <code>vendor/</code> for packages first, before it searches outside your project directory. Just leave <code>$GOPATH</code> set to <code>$HOME/go</code>. You shouldn't ever have to change your <code>$GOPATH</code> after you set it the first time.</p></pre>dlsniper: <pre><p>You are wrong. You MUST set the GOPATH and the project MUST be in the GOPATH before it can use the vendoring approach.</p></pre>Destructicorn: <pre><p>Thanks, I wasn't aware it searched the <code>vendor/</code> folder. I assumed since there is no official package management yet that <code>go build</code> would just ignore <code>vendor/</code>. </p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传