英文:
Cannot install docker pkg dependency in Go
问题
我正在尝试在我的Go应用程序中使用docker包。我在脚本中导入包的方式是import "github.com/dotcloud/docker"
。但是当我尝试构建依赖项时,也就是在项目目录中运行go get
时,它显示:
foo.go:9:2: 在 /home/neville/gocode/src/github.com/dotcloud/docker 中没有可构建的Go源文件
在这里,我的GOPATH
设置为/home/neville/gocode
,所以当执行go get
时,该包应该被下载到/home/neville/gocode/pkg
,而不是/home/neville/gocode/src
。我在这里漏掉了什么?
英文:
I'm trying to use the docker package in one of my Go applications. I'm importing the package as import "github.com/dotcloud/docker"
in my script. But when trying to build the dependencies, that is, when I run go get
in my project directory, it says:
foo.go:9:2: no buildable Go source files in /home/neville/gocode/src/github.com/dotcloud/docker
Here, my GOPATH
is set to /home/neville/gocode
, so when doing go get
, the package should get downloaded to /home/neville/gocode/pkg
, instead of /home/neville/gocode/src
. What am I missing here?
答案1
得分: 2
github.com/dotcloud/docker
不是一个 Go 包,这就是为什么在该目录中没有源文件的原因。
直接导入你想要的包,比如 registry 包,可以这样做:
import "github.com/dotcloud/docker/registry"
另外,go get
确实会将下载的文件放在 $GOPATH/src
目录下。而安装的目标文件会放在 $GOPATH/pkg
目录下。
英文:
github.com/dotcloud/docker
isn't a Go package, and that's why there are no source files in that directory.
Import the package you want directly, like so for the registry package:
import "github.com/dotcloud/docker/registry"
Also, go get
does download into $GOPATH/src
. The installed object files go in $GOPATH/pkg
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论