构建.go包时出现致命错误

时间:2017-03-19 10:35:36

标签: go

我正在尝试安装go包。我克隆了包,运行以下命令来构建它:

$go get -v -d

Fetching https://golang.org/x/net/publicsuffix?go-get=1
Parsing meta tags from https://golang.org/x/net/publicsuffix?go-get=1 (status code 200)
get "golang.org/x/net/publicsuffix": found meta tag main.metaImport{Prefix:"golang.org/x/net", VCS:"git", RepoRoot:"https://go.googlesource.com/net"} at https://golang.org/x/net/publicsuffix?go-get=1
get "golang.org/x/net/publicsuffix": verifying non-authoritative meta tag
Fetching https://golang.org/x/net?go-get=1
Parsing meta tags from https://golang.org/x/net?go-get=1 (status code 200)
golang.org/x/net (download)

$go build *.go
# github.com/moul/http2curl
gccgo: error: $HOME/go/src/github.com/moul/http2curl/http2curl.go: No such file or directory
gccgo: fatal error: no input files
compilation terminated.
# github.com/pkg/errors
gccgo: error: $HOME/go/src/github.com/pkg/errors/errors.go: No such file or directory
gccgo: error: $HOME/go/src/github.com/pkg/errors/stack.go: No such file or directory
gccgo: fatal error: no input files
compilation terminated.
# golang.org/x/net/publicsuffix
gccgo: error: $HOME/go/src/golang.org/x/net/publicsuffix/list.go: No such file or directory
gccgo: error: $HOME/go/src/golang.org/x/net/publicsuffix/table.go: No such file or directory
gccgo: fatal error: no input files
compilation terminated.

我尝试将github.com/moul/http2curl克隆到$ HOME / go / src / github.com / moul / http2curl,http2curl.go文件正好在指定的路径中,但它仍然说没有这样的文件或目录。 我如何建立这个?

1 个答案:

答案 0 :(得分:1)

我不确定普通go get -v -d会给你什么,但你应该指定你想要安装的软件包。 所以你应该做的是这样的事情:

$go get github.com/moul/http2curl

如果没有-d标记,则应为您下载并安装http2curl。但是如果您使用-d标志,则可以先安装包来安装包。

$cd $GOPATH/src/github.com/moul/http2curl

然后运行build(没有* .go)。

$go build