go test import errors

时间:2017-04-28 05:29:01

标签: http go gopath

我已使用git clone https://go.googlesource.com/gogo source code克隆到我的~/godev/目录中。

我的$ GOPATH是~/gocode

我安装了使用安装程序

如果我进入~/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 .按照说明here后,我仍然会收到以下错误:

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个错误。

1 个答案:

答案 0 :(得分:0)

实际上, golang_org 包不是root包,你的代码需要它才能构建而无法找到它。你必须去获取以下包裹。

/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