我在GitHub(https://github.com/IBM-Blockchain/learn-chaincode)中关注Bluemix Blockchain教程学习链代码,但在初始构建时失败了。
错误消息是:
/d/work/src/github.com/learn-chaincode/start (master)
$ go build ./
chaincode_start.go:23:2: cannot find package "github.com/hyperledger/fabric/core/chaincode/shim" in any of:
D:\opt\Go\src\github.com\hyperledger\fabric\core\chaincode\shim (from $GOROOT)
D:\work\src\github.com\hyperledger\fabric\core\chaincode\shim (from $GOPATH)
我按照设置环境的初始设置进行了操作:
$ go get github.com/hyperledger-archives/fabric/tree/v0.5-developer-preview/core/chaincode/shim
package github.com/hyperledger-archives/fabric/tree/v0.5-developer-preview/core/chaincode/shim: cannot find package "github.com/hyperledger-archives/fabric/tree/v0.5-developer-preview/core/chaincode/shim" in any of:
D:\opt\Go\src\github.com\hyperledger-archives\fabric\tree\v0.5-developer-preview\core\chaincode\shim (from $GOROOT)
D:\work\src\github.com\hyperledger-archives\fabric\tree\v0.5-developer-preview\core\chaincode\shim (from $GOPATH)
结果是它填充了目录hyperledger-archives。
$ ls $GOPATH/src/github.com/hyperledger-archives/fabric/
bddtests/ docs/ LICENSE peer/ sdk/
consensus/ events/ MAINTAINERS.txt protos/ tools/
CONTRIBUTING.md examples/ Makefile pub/ TravisCI_Readme.md
core/ gotools/ membersrvc/ README.md vendor/
devenv/ images/ mkdocs.yml scripts/
但是你可以看到没有D:\ work \ src \ github.com \ hyperledger-archives \ fabric \ tree。
我做错了什么?
答案 0 :(得分:0)
确保Hyperledger Fabric位于GOPATH目录中可以解决此问题。 Learn Chaincode教程(https://github.com/IBM-Blockchain/learn-chaincode)引用了先决条件“Chaincode Development Environment”部分:https://github.com/IBM-Blockchain/learn-chaincode/blob/v1.0/docs/setup.md
“Chaincode Development Environment”部分的“Instructions”标题提到的错误几乎与观察到的以下错误相同。
$ go build ./
chaincode_start.go:23:2: cannot find package "github.com/hyperledger/fabric/core/chaincode/shim" in any of:
D:\opt\Go\src\github.com\hyperledger\fabric\core\chaincode\shim (from $GOROOT)
D:\work\src\github.com\hyperledger\fabric\core\chaincode\shim (from $GOPATH)
错误的原因可能是在GOPATH中没有正确安装Hyperledger Fabric。