-2

我已经将 go 源代码克隆到git clone https://go.googlesource.com/go~/godev/目录中。

我的 $GOPATH 是~/gocode

我使用安装程序安装了 go

如果我 cd into~/godev/go/src/net/http并运行go test,我会收到以下错误:

h2_bundle.go:46:2: cannot find package "golang_org/x/net/http2/hpack" in any of:
    /usr/local/go/src/golang_org/x/net/http2/hpack (from $GOROOT)
    ~/gocode/src/golang_org/x/net/http2/hpack (from $GOPATH)
h2_bundle.go:47:2: cannot find package "golang_org/x/net/idna" in any of:
    /usr/local/go/src/golang_org/x/net/idna (from $GOROOT)
    ~/gocode/src/golang_org/x/net/idna (from $GOPATH)
h2_bundle.go:48:2: cannot find package "golang_org/x/net/lex/httplex" in any of:
    /usr/local/go/src/golang_org/x/net/lex/httplex (from $GOROOT)
    ~/gocode/src/golang_org/x/net/lex/httplex (from $GOPATH)
transport.go:32:2: cannot find package "golang_org/x/net/proxy" in any of:
    /usr/local/go/src/golang_org/x/net/proxy (from $GOROOT)
    ~/gocode/src/golang_org/x/net/proxy (from $GOPATH)
transfer.go:14:2: use of internal package not allowed

在我按照此处的说明进行操作cd $GOPATH/src 之后cp -R /usr/local/go/src/vendor/golang_org .,我仍然会收到以下错误:

h2_bundle.go:47:2: 目录 ~/gocode/src/golang_org/x/net/idna 中的代码需要导入“golang.org/x/net/idna” transport.go:32:2: 找不到包“golang_org /x/net/proxy” 在以下任何一个中:/usr/local/go/src/golang_org/x/net/proxy(来自 $GOROOT)~/gocode/src/golang_org/x/net/proxy(来自 $GOPATH) transfer.go:14:2:不允许使用内部包

确实 ~/gocode/src/golang_org/x/net 下没有代理包,但是即使我以某种方式修复了它,我也不理解其他 2 个错误。

4

1 回答 1

0

实际上,包golang_org不是根包,您的代码需要它来构建并且找不到它。只需您必须去获取以下包。

/usr/local/go/src/golang_org/x/net/http2/hpack (from $GOROOT)
/Users/lf215/go/src/golang_org/x/net/http2/hpack (from $GOPATH)

这个版本的 Go 存在一些问题。你可以参考 https://github.com/constabulary/gb/issues/635

于 2017-04-28T05:54:19.547 回答