I am trying to follow instructions on Chaincode Development Environment to setup hyperledger in my local environment.
Unfortunately, I am completely new to golang. When I come across an error trying to build "chaintool/example02" I have no idea how to proceed further - should I ignore the issue or first I should fix something? For example, to run make with some options, etc ... How can I get missing imports ?
The output looks as follows:
hyper-00:chaincode hyper$ pwd
/Users/hyper/Projects/blockchain/src/github.com/hyperledger/fabric/examples/chaincode/chaintool/example02/src/chaincode
hyper-00:chaincode hyper$ go build ./
chaincode_example02.go:24:2: cannot find package "hyperledger/cci/appinit" in any of:
/Users/hyper/Projects/blockchain/src/github.com/hyperledger/fabric/vendor/hyperledger/cci/appinit (vendor tree)
/usr/local/go/src/hyperledger/cci/appinit (from $GOROOT)
/Users/hyper/Projects/blockchain/src/hyperledger/cci/appinit (from $GOPATH)
chaincode_example02.go:25:2: cannot find package "hyperledger/cci/org/hyperledger/chaincode/example02" in any of:
/Users/hyper/Projects/blockchain/src/github.com/hyperledger/fabric/vendor/hyperledger/cci/org/hyperledger/chaincode/example02 (vendor tree)
/usr/local/go/src/hyperledger/cci/org/hyperledger/chaincode/example02 (from $GOROOT)
/Users/hyper/Projects/blockchain/src/hyperledger/cci/org/hyperledger/chaincode/example02 (from $GOPATH)
chaincode_example02.go:26:2: cannot find package "hyperledger/ccs" in any of:
/Users/hyper/Projects/blockchain/src/github.com/hyperledger/fabric/vendor/hyperledger/ccs (vendor tree)
/usr/local/go/src/hyperledger/ccs (from $GOROOT)
/Users/hyper/Projects/blockchain/src/hyperledger/ccs (from $GOPATH)
hyper-00:chaincode hyper$
My $GOPATH gives:
hyper-00:~ hyper$ echo $GOPATH
/Users/hyper/Projects/blockchain
[EDITED on 2017-01-02]
I repeated the repo cloning procedure again. I think my mistake was I pulled a wrong source from GitHub - probably "master", not "v0.6".
What I did and the compilation works now is:
$ sudo apt install golang-go
$ gedit .profile
export PATH=$PATH:/usr/local/go/bin
export GOPATH=$HOME/Projects/blockchain
$ . ~/.profile
$ mkdir -p $GOPATH/src/github.com/hyperledger/
$ cd $GOPATH/src/github.com/hyperledger
$ git clone -b v0.6 http://gerrit.hyperledger.org/r/fabric
$ cd ~/Projects/blockchain/src/github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02
$ go build
The HyperLedger team has provided very good documentation on how to use chaintool in a manner that allows users to document APIs (via Chain Code Interface, or CCI). Without this, consumers of a chaincode must inspect source code to understand how to compose a REST invocation. Great idea.
This approach to building chaincode requires you download github.com/hyperledger/cci and github.com/hyperledger/ccs to reside next to github.com/hyperledger/fabric within your $GOPATH. Unfortunately, I don't see any repository (on either github or gerrit) where this can be downloaded.
Further, I've only seen one example (thus far) of how to use chaintool with cci and ccs, which is chaintool/example02... and it does not compile due to these missing hyperledger packages.
There is documentation on chaintool with cci/ccs support at the following location:
But it seems this documentation has been copied to the following location and renamed from 'chaintool' to 'openblockchain compiler' (or OBCC) and labeled as a 'work in progress':
As such, I am inclined to believe the chaintool/example02 is not a currently supported approach to building chaincode... at least until OBCC becomes officially available.