I have done basic setup in Hyperledger Fabric 1.4.7 and made all peer's to join the channel. After exploring chaincode in golang, I started trying chaincode install command and I was facing issue's in this step.
error
Error: error getting chaincode code mycc: path to chaincode does not exist: /home/user899/go/src/chaincode
When I just ran go run chaincode.go
error
chaincode.go:7:2: cannot find package "github.com/hyperledger/fabric-chaincode-go/shim" in any of: /usr/lib/go-1.14/src/github.com/hyperledger/fabric-chaincode-go/shim (from $GOROOT) /home/user899/go/src/github.com/hyperledger/fabric-chaincode-go/shim (from $GOPATH) chaincode.go:8:2: cannot find package "github.com/hyperledger/fabric-protos-go/peer" in any of: /usr/lib/go-1.14/src/github.com/hyperledger/fabric-protos-go/peer (from $GOROOT) /home/user899/go/src/github.com/hyperledger/fabric-protos-go/peer (from $GOPATH)
Environments
echo $GOPATH
/home/user899/go
Chaincode location
/home/user899/SoloNetwork/chaincode
Can anyone help.
Thanks
I'm answering my own question. Here is the solution, I was not aware of the directory structure that need's to be followed in Go.
So first, I checked my GOPATH(usually the workspace where we can write all our go files) using
go envin the terminal it was located underhome/dev/goAnd coming about the directory structure it should be followed as following :-
$GOPATH + /src/github.com/chaincode, So the final structure will be
home/dev/go/src/github.com/chaincodeinside chaincode. I can place all Go files.So after getting chaincode file from here, I have placed in the above location and executed the following commands
go mod initgo mod tidyThen, I was able to execute peer chaincode install commad
peer chaincode install -n mycc -p "github.com/chaincode" -v 1.0Here in the command
-p "github.com/chaincode"is the folder name that I have created.So finally chaincode path is created by these :
$GOPATH + src + -p flagIf anyone is facing, go binary related issue's set your GOROOT path to the bin location where go is intalled.