Cannot compile chaincode

eugenn picture eugenn · Oct 10, 2016 · Viewed 6.9k times · Source

I am trying to compile the chaincode_example02 followed by this guide with Option 2 (for Mac). All steps were passed except compiling the code. I have the following error:

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)

Answer

Nhan Cao picture Nhan Cao · Nov 16, 2018

You need to prepare the fabric source as libs follow command. Make sure GOPATH had been set first.

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