5

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)
eugenn
  • 1,638
  • 6
  • 23
  • 38

4 Answers4

7

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
Nhan Cao
  • 2,496
  • 1
  • 17
  • 13
5

“Fabric” source code should be available locally in your GOPATH.

cd $GOPATH/src/github.com
mkdir hyperledger
cd hyperledger
git clone http://gerrit.hyperledger.org/r/fabric
Sergey Balashevich
  • 2,101
  • 14
  • 11
  • Based on your description the "chaincode_example02" is in "$GOPATH/src/github.com/" folder. is it just a copy of "$GOPATH/src/github.com/hyperledger/fabric/examples/chaincode/go/asset_management02" ? – Sergey Balashevich Oct 10 '16 at 14:33
1

As it says in the error message, your GOPATH environment variable is not set correctly.

Before doing a go build on the chaincode:

  1. Make sure your GOPATH is set up correctly

  2. Make sure you have the fabric code in your GOPATH

Clyde D'Cruz
  • 1,915
  • 1
  • 14
  • 36
0

change the import statement to github.com/hyperledger/fabric-chaincode-go/shim and use "go get github.com/hyperledger/fabric-chaincode-go/shim"

Rugved Mahamune
  • 546
  • 1
  • 5
  • 8