无法在Go中安装Docker软件包依赖。

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

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.

huangapple
  • 本文由 发表于 2014年7月2日 22:05:30
  • 转载请务必保留本文链接:https://go.coder-hub.com/24533238.html
匿名

发表评论

匿名网友

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

确定