我正在尝试编译chaincode_example02,然后使用选项2(对于Mac)编译guide。除编译代码外,所有步骤均已通过。我有以下错误:
cd $GOPATH/src/github.com/chaincode_example02
go build
chaincode_example02.go:30:2: cannot find package "github.com/hyperledger/fabric/core/chaincode/shim" in any of:
/usr/local/Cellar/go/1.7.1/libexec/src/github.com/hyperledger/fabric/core/chaincode/shim (from $GOROOT)
($GOPATH not set)
“Fabric”源代码应该在您的GOPATH中本地可用。
cd $GOPATH/src/github.com
mkdir hyperledger
cd hyperledger
git clone http://gerrit.hyperledger.org/r/fabric
您需要以libs follow命令准备Fabric结构源。确保首先设置了GOPATH。
mkdir -p $GOPATH/src/github.com/hyperledger
cd $GOPATH/src/github.com/hyperledger
git clone -b release-1.2 https://github.com/hyperledger/fabric.git
正如它在错误消息中所述,您的GOPATH
环境变量未正确设置。
在对链码进行构建之前:
GOPATH
设置正确
按照本指南https://golang.org/doc/code.html#GOPATH)
做echo $GOPATH
检查GOPATH
的价值GOPATH
中有结构代码