dtxpz8785 2019-03-12 07:06
浏览 183

在Docker容器中使用Go模块时找不到包错误

Given I have some experience working with docker containers I decided to use docker containers to have a go environment and learn. Below is my dockerfile for go web app.

FROM golang:1.12.0-alpine3.9 as base

ARG GO111MODULE=on

RUN apk update && apk add make bash git

COPY ./app /go/src/app
WORKDIR /go/src/app
RUN go build

COPY ./compose/local/golang/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

RUN go get github.com/oxequa/realize

ENTRYPOINT [ "/entrypoint.sh" ]
CMD ["realize", "start"]

My go.mod file

module github.com/rajeshyogeshwar/demoapp

go 1.12

require (
    github.com/Sirupsen/logrus v1.0.6
    github.com/joho/godotenv v1.3.0
    github.com/julienschmidt/httprouter v1.2.0
    github.com/lib/pq v1.0.0
    github.com/spf13/cobra v0.0.3
    github.com/spf13/viper v1.2.0
)

and finally my project folder structure

enter image description here

As we can see I am trying to use httprouter module and it has been defined in my go.mod file. But I keep getting following error.

app_1        | [06:46:56][APP] : Install 
app_1        |  main.go:8:2: cannot find package "github.com/julienschmidt/httprouter" in any of:
app_1        |  /usr/local/go/src/github.com/julienschmidt/httprouter (from $GOROOT)
app_1        |  /go/src/github.com/julienschmidt/httprouter (from $GOPATH)

So if anyone can point out the obvious mistake it would be great.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 Jenkins自动化部署—悬赏100元
    • ¥15 关于#python#的问题:求帮写python代码
    • ¥20 MATLAB画图图形出现上下震荡的线条
    • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
    • ¥15 perl MISA分析p3_in脚本出错
    • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
    • ¥15 ubuntu虚拟机打包apk错误
    • ¥199 rust编程架构设计的方案 有偿
    • ¥15 回答4f系统的像差计算
    • ¥15 java如何提取出pdf里的文字?