英文:
Fatal error when building .go package
问题
我正在尝试安装一个Go包。我克隆了这个包,并运行以下命令来构建它:
$go get -v -d
正在获取 https://golang.org/x/net/publicsuffix?go-get=1
正在解析元标签 https://golang.org/x/net/publicsuffix?go-get=1 (状态码 200)
获取 "golang.org/x/net/publicsuffix":在 https://golang.org/x/net/publicsuffix?go-get=1 找到元标签 main.metaImport{Prefix:"golang.org/x/net", VCS:"git", RepoRoot:"https://go.googlesource.com/net"}
获取 "golang.org/x/net/publicsuffix":正在验证非权威的元标签
正在获取 https://golang.org/x/net?go-get=1
正在解析元标签 https://golang.org/x/net?go-get=1 (状态码 200)
golang.org/x/net (下载)
$go build *.go
# github.com/moul/http2curl
gccgo: 错误: $HOME/go/src/github.com/moul/http2curl/http2curl.go: 没有那个文件或目录
gccgo: 致命错误: 没有输入文件
编译终止。
# github.com/pkg/errors
gccgo: 错误: $HOME/go/src/github.com/pkg/errors/errors.go: 没有那个文件或目录
gccgo: 错误: $HOME/go/src/github.com/pkg/errors/stack.go: 没有那个文件或目录
gccgo: 致命错误: 没有输入文件
编译终止。
# golang.org/x/net/publicsuffix
gccgo: 错误: $HOME/go/src/golang.org/x/net/publicsuffix/list.go: 没有那个文件或目录
gccgo: 错误: $HOME/go/src/golang.org/x/net/publicsuffix/table.go: 没有那个文件或目录
gccgo: 致命错误: 没有输入文件
编译终止。
我尝试将 github.com/moul/http2curl 克隆到 $HOME/go/src/github.com/moul/http2curl,并且 http2curl.go 文件确实在指定的路径中,但仍然显示"没有那个文件或目录"。我该如何构建它?
英文:
I'm trying to install a go package. I cloned the package, ran the following commands to build it:
$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.
I tried cloning github.com/moul/http2curl to $HOME/go/src/github.com/moul/http2curl and the http2curl.go file is exactly in the path specified and yet it still says No such file or directory.
How do I build this?
答案1
得分: 1
我不确定纯粹的 go get -v -d
命令会得到什么结果,但你应该指定你想要安装的包。
所以你应该这样做:
$go get github.com/moul/http2curl
不带 -d
标志,这将为你下载并安装 http2curl
包。但如果你使用 -d
标志,你可以通过首先进入包的目录来安装该包。
$cd $GOPATH/src/github.com/moul/http2curl
然后运行构建命令(不带 *.go)。
$go build
英文:
I'm not sure what plain go get -v -d
gets you but you should specify the package(s) that you want to install.
So what you should do is something like this:
$go get github.com/moul/http2curl
Without the -d
flag this should download and install the package http2curl
for you. But if you use the -d
flag, you can install the package by first moving to the package's directory.
$cd $GOPATH/src/github.com/moul/http2curl
And then running build (without *.go).
$go build
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论