我正在写在GO一个简单的应用程序,我有这样的文件夹结构搬运工,撰写找不到包(golang)
泊坞窗,compose.yml文件内容是:
version: '2'
services:
db:
image: rethinkdb:latest
ports:
- "38080:8080"
- "38015:28015"
- "39015:29015"
api:
image: golang:1.8-alpine
volumes:
- .:/go/src/test_server/
working_dir: /go/src/test_server
command: go run server.go
container_name: test_server
ports:
- "8085:8085"
links:
- db
tty: true
每次我跑码头工人,组成了我收到此错误信息:
test_server | controllers/users.go:4:3: cannot find package "_/go/src/test_server/vendor/github.com/gin-gonic/gin" in any of: test_server |
/usr/local/go/src/_/go/src/test_server/vendor/github.com/gin-gonic/gin (from $GOROOT) test_server |
/go/src/_/go/src/test_server/vendor/github.com/gin-gonic/gin (from $GOPATH)
它指的是控制器包。我正在使用github.com/kardianos/govendor来供应我的软件包。你知道发生了什么事吗?
我做到了,但它不起作用,现在的错误信息是这样的: test_server | ers/users.go:4:3:无法在以下任何位置找到软件包“github.com/gin-gonic/gin”: test_server | /usr/local/go/src/github.com/gin-gonic/gin(来自$ GOROOT) test_server | /go/src/test_server/src/github.com/gin-gonic/gin(from $ GOPATH) 我尝试过使用Dockerfile,因为我虽然是更优雅的解决方案,但每次构建它时,都会出现错误: 这是Dockerfile内容: FROM golang:1.8高山 RUN去拿github.com/gin-gonic/gin EXPOSE 8085 – utiq
https://www.evernote.com/l/ADkxl1UoBy1IsYPq4u_YhyzR-N8FfIwZQCs – utiq