doufuxi7093 2019-05-23 16:39
浏览 128

去docker错误中获取golang-migrate

I am trying to set up a small first time app in go using Docker. I want to use the cli tools for go-lang migrate. However I receive the following error:

package github.com/golang-migrate/migrate/v4/internal/cli: cannot find package "github.com/golang-migrate/migrate/v4/internal/cli" in any of: /usr/local/go/src/github.com/golang-migrate/migrate/v4/internal/cli (from $GOROOT) /go/src/github.com/golang-migrate/migrate/v4/internal/cli (from $GOPATH)

The command works fine outside of docker. I'm confused about the set up of my Dockerfile, my GOPATH appears to be fine as well.

I have a Dockerfile with the following lines:


RUN apk --update add alpine-sdk

WORKDIR $GOPATH/src/github.com/go-projects/docker-test/

RUN echo $GOPATH

RUN go get -u -d github.com/golang-migrate/migrate/cli github.com/lib/pq```
  • 写回答

1条回答 默认 最新

  • du1843 2019-05-24 16:58
    关注

    I was able to get this working in a Docker container with the following:

    FROM golang:1.12rc1-alpine3.9 AS build  # or replace with your desired build
    
    RUN apk --update add alpine-sdk
    
    COPY . $GOPATH/src/github.com/go-projects/docker-test/
    
    WORKDIR $GOPATH/src/github.com/go-projects/docker-test/
    
    RUN echo $GOPATH
    
    RUN go get -u -d github.com/golang-migrate/migrate github.com/lib/pq
    

    Additionally, it is suggested to use cmd/migrate instead of cli per this commit

    评论

报告相同问题?

悬赏问题

  • ¥30 VMware 云桌面水印如何添加
  • ¥15 用ns3仿真出5G核心网网元
  • ¥15 matlab答疑 关于海上风电的爬坡事件检测
  • ¥88 python部署量化回测异常问题
  • ¥30 酬劳2w元求合作写文章
  • ¥15 在现有系统基础上增加功能
  • ¥15 远程桌面文档内容复制粘贴,格式会变化
  • ¥15 这种微信登录授权 谁可以做啊
  • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”