为了账号安全,请及时绑定邮箱和手机立即绑定

Dockerfile 无法下载模块

Dockerfile 无法下载模块

Go
PIPIONE 2022-10-24 16:02:28
我有以下代码结构notificator|    Dockerfile|    go.mod|    go.sum|    notificator.pb.go|+-- cmd|   .go files+-- pkg    .go files以下 Dockerfile 成功构建:FROM golangWORKDIR /notificatorCOPY . .RUN go get  -t -v ./...RUN mkdir binRUN go build -o bin ././...RUN chmod +x bin/cmdENTRYPOINT [ "./bin/cmd" ]但是当我将它重构为:FROM golangWORKDIR /notificatorCOPY go.mod .COPY go.sum .RUN go mod downloadCOPY . .RUN mkdir binRUN go build -o bin ././...RUN chmod +x bin/cmdENTRYPOINT [ "./bin/cmd" ]go mod 下载返回以下错误:#12 0.816 /go/pkg/mod/github.com/go-kit/kit@v0.12.0/sd/etcd/client.go:13:2: missing go.sum entry for module providing package go.etcd.io/etcd/client/v2 (imported by github.com/go-kit/kit/sd/etcd); to add:#12 0.816   go get github.com/go-kit/kit/sd/etcd@v0.12.0但是 go.sum 包含:go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs=go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g=go.etcd.io/etcd/client/v2 v2.305.0/go.mod h1:h9puh54ZTgAKtEbut2oe9P4L/oqKCVB6xsXlzd7alYQ=go.etcd.io/etcd/client/v3 v3.5.0/go.mod h1:AIKXXVX/DQXtfTEqBryiLTUXwON+GuvO6Z7lLS/oTh0=我不明白为什么这两个文件的行为不同?
查看完整描述

1 回答

?
森林海

TA贡献2011条经验 获得超2个赞

运行go mod tidy解决了问题



查看完整回答
反对 回复 2022-10-24
  • 1 回答
  • 0 关注
  • 104 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信