Dependency path issues setting up Dep with Docker

xuanbao · 2018-03-12 16:30:12 · 625 次点击    
这是一个分享于 2018-03-12 16:30:12 的资源,其中的信息可能已经有所发展或是发生改变。

Hi guys, I'm stuck on this Dep issue that I can't fix, it's probably something stupid that I'm missing, maybe you can give me some hints on it.

I've got my Go project running in a Docker container. I install and manage my dependencies with Dep. So far so good until I'm trying to split my code in a different package. The sub-packages won't find my vendor dependencies installed with Dep anymore.

When I move all my files back to one folder and rename everything back to "main" package it starts working.

This is the error I get:

root@c348fbca321e:/go# go run src/my-lib/main.go
src/my-lib/mySubLib/db.go:6:2: cannot find package "_/go/src/my-lib/vendor/github.com/go-sql-driver/mysql" 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)

And here is a public GitHub repo with my entire setup and installation steps: https://github.com/doomhz/my-go-project

Any idea how to fix this? Any help would be much appreciated. Thanks in advance.


评论:

edwinTop:

you can put them back in multiple directory, but your docker file should look something like this..

FROM golang:alpine
WORKDIR /go/src/github.com/doomhz/my-go-project
COPY . .
RUN go get -d -v ./...
RUN go install -v ./...
ENTRYPOINT ["my-go-project"]

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

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