Dependency path issues setting up Dep with Docker

xuanbao · · 430 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Hi guys, I&#39;m stuck on this Dep issue that I can&#39;t fix, it&#39;s probably something stupid that I&#39;m missing, maybe you can give me some hints on it.</p> <p>I&#39;ve got my Go project running in a Docker container. I install and manage my dependencies with Dep. So far so good until I&#39;m trying to split my code in a different package. The sub-packages won&#39;t find my vendor dependencies installed with Dep anymore.</p> <p>When I move all my files back to one folder and rename everything back to &#34;main&#34; package it starts working.</p> <p>This is the error I get:</p> <pre><code>root@c348fbca321e:/go# go run src/my-lib/main.go src/my-lib/mySubLib/db.go:6:2: cannot find package &#34;_/go/src/my-lib/vendor/github.com/go-sql-driver/mysql&#34; in any of: /usr/local/go/src/_/go/src/my-lib/vendor/github.com/go-sql-driver/mysql (from $GOROOT) /go/src/_/go/src/my-lib/vendor/github.com/go-sql-driver/mysql (from $GOPATH) </code></pre> <p>And here is a public GitHub repo with my entire setup and installation steps: <a href="https://github.com/doomhz/my-go-project" rel="nofollow">https://github.com/doomhz/my-go-project</a></p> <p>Any idea how to fix this? Any help would be much appreciated. Thanks in advance.</p> <hr/>**评论:**<br/><br/>edwinTop: <pre><p>you can put them back in multiple directory, but your docker file should look something like this..</p> <pre><code>FROM golang:alpine WORKDIR /go/src/github.com/doomhz/my-go-project COPY . . RUN go get -d -v ./... RUN go install -v ./... ENTRYPOINT [&#34;my-go-project&#34;] </code></pre></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

430 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传