[英]“cannot find module providing for package” in go
Im trying to install the official go docker client by importing 我正在尝试通过导入来安装官方的go docker客户端
"github.com/docker/docker/client" “github.com/docker/docker/client”
But i get the following error 但是我收到以下错误
cannot load github.com/docker/distribution/reference: cannot find module providing package github.com/docker/distribution/reference 无法加载github.com/docker/distribution/reference:无法找到提供软件包github.com/docker/distribution/reference的模块
My go version is 1.12 and my project is outside $GOPATH/src. 我的go版本是1.12,我的项目在$ GOPATH / src之外。 My go.mod file looks like this.
我的go.mod文件看起来像这样。
module app
go 1.12
require (
github.com/Microsoft/go-winio v0.4.14 // indirect
github.com/docker/docker v1.13.1
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.4.0 // indirect
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 // indirect
)
Based on docker documentation , it says that you have to execute go get github.com/docker/docker/client
command to download it. 根据
go get github.com/docker/docker/client
文档 ,它说您必须执行go get github.com/docker/docker/client
命令来下载它。 Once library is retrieved it should compile. 一旦检索到库,就应该编译。
I remember that I had similar problems as you 1.5-2 monthes ago. 我记得我在1.5-2个月前遇到过类似的问题。
My observations : 我的观察 :
I did not found answers for "what actually describes official documentation?" 我没有找到“实际上描述了官方文档?”的答案。 or "where actually docker API repo?"
或“码头工人API回购实际上在哪里?”
I gave up on attempts to solve in "official way" and found that more practical to use "unofficial" 我放弃了尝试以“官方方式”解决的尝试,发现使用“非官方”方式更实用
"Unofficial way" : “非官方方式” :
docker-ce
repo. docker-ce
repo中搜索代码。 docker/client
usage I found here: components/engine/integration/internal/container/exec.go (note that it resides in internal
and is impossible to be used as package) docker/client
使用的最佳示例: components / engine / integration / internal / container / exec.go (请注意,它位于internal
,无法用作包) Maybe it's "incorrect" solution but it worked for me. 也许这是“不正确”的解决方案,但对我有用。
I suppose it could be more practical for you to not rely on docker documentation too. 我认为不依赖docker文档可能对您来说更实用。
Good luck! 祝好运!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.