go-kit在go.sum中缺少模块的条目。

huangapple go评论83阅读模式
英文:

go-kit missing entry for module in go.sum

问题

我正在通过一个关于go-kit的教程,该教程使用etcd进行服务发现。我正在使用Goland在本地构建一个多容器架构,并且刚刚到达了将一个服务(notificator)注册到etcd的部分。

一切看起来都很好,但是当我运行:

docker-compose up --build notificator

我得到了以下错误:

#12 7.248 /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 7.248 	go get github.com/go-kit/kit/sd/etcd@v0.12.0

当我运行go get github.com/go-kit/kit/sd/etcd@v0.12.0,然后重新运行docker-compose up --build notificator时,错误仍然存在,尽管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=

go.mod文件内容如下:

module notificator

go 1.15

require (
	github.com/go-kit/kit v0.12.0
	github.com/lightstep/lightstep-tracer-go v0.25.0
	github.com/oklog/oklog v0.3.2
	github.com/oklog/run v1.1.0 // indirect
	github.com/opentracing/basictracer-go v1.1.0 // indirect
	github.com/opentracing/opentracing-go v1.2.0
	github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5
	github.com/openzipkin/zipkin-go v0.3.0
	github.com/prometheus/client_golang v1.11.0
	golang.org/x/net v0.0.0-20211216030914-fe4d6282115f
	google.golang.org/grpc v1.43.0
	google.golang.org/protobuf v1.27.1
	sourcegraph.com/sourcegraph/appdash v0.0.0-20211028080628-e2786a622600
)

我不确定如何解释这个问题,因为在我看来,条件已经满足了。我还以为这个会自动导入?

英文:

I am working my way through a tutorial on go-kit which is using etcd for service discovery. I am using Goland to build a multi-container architecture locally and have just got to the bit where one service (notificator) is being registered in etcd.

All seems fine but when I run:

docker-compose up --build notificator

I get:

#12 7.248 /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 7.248 	go get github.com/go-kit/kit/sd/etcd@v0.12.0

When I do run go get github.com/go-kit/kit/sd/etcd@v0.12.0 then rerun docker-compose up --build notificator the error persists even though go.sum contains the following:

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=

go.mod is:

module notificator

go 1.15

require (
	github.com/go-kit/kit v0.12.0
	github.com/lightstep/lightstep-tracer-go v0.25.0
	github.com/oklog/oklog v0.3.2
	github.com/oklog/run v1.1.0 // indirect
	github.com/opentracing/basictracer-go v1.1.0 // indirect
	github.com/opentracing/opentracing-go v1.2.0
	github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5
	github.com/openzipkin/zipkin-go v0.3.0
	github.com/prometheus/client_golang v1.11.0
	golang.org/x/net v0.0.0-20211216030914-fe4d6282115f
	google.golang.org/grpc v1.43.0
	google.golang.org/protobuf v1.27.1
	sourcegraph.com/sourcegraph/appdash v0.0.0-20211028080628-e2786a622600
)

Not sure how to interpret that as it looks to me the condition is satisfied ?? I also thought that would have been automatically imported?

答案1

得分: 1

这似乎是我的Dockerfile出了问题。

COPY go.mod .
COPY go.sum .
RUN go mod download

会产生上述错误,而

COPY . .
RUN go get  -t -v ./...

则不会。我不完全确定原因,所以我会提出另一个问题。

英文:

This turns out to be an issue with my Dockerfile.

COPY go.mod .
COPY go.sum .
RUN go mod download

will produce the above error, while

COPY . .
RUN go get  -t -v ./...

does not. I am not entirely sure why so will open another question.

huangapple
  • 本文由 发表于 2022年1月11日 01:01:42
  • 转载请务必保留本文链接:https://go.coder-hub.com/70656185.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定