First, make sure Golang binary has been installed correctly. The official Go installation document. The Go versions
>=1.10.1, <1.11 have been tested and are suggested to use. To verify Go is correctly installed, you can run the following commands:
$ go version
go version go1.10.1
$ go env GOPATH
Please download go-sdk-demo-1.4.5. Download sample codes to local directory:
$GOPATH/src, and decompress it. Copy file
connection-profile.yaml to path
$GOPATH/src/go-sdk-demo. The layout of the workspace should look like this:
play.sh: An entry script that provides an interactive command line interface.
main.go: An example program based on Hyperledger Fabric Go SDK.
chaincode/sacc.out: A packaged chain code, it can be uploaded directly to BaaS console.
chaincode/src: The source codes of sacc.out.
vendor/github.com/hyperledger/fabric-sdk-go: The source codes of Hyperledger Fabric Go SDK.
Upload the chaincode:
chaincode/sacc.out to BaaS and instantiate it. You can refer to Deploy chaincodes.
Follow the prompts to enter some necessary information.
play.sh will run
main.go, which is a sample program based on the Hyperledger Fabric Go SDK, mainly to help you understand the basic usage of Go SDK. It includes the following functions:
- Enroll a user, download certificates.
- Query channel config and print it in console.
- Query channel info and print it in console.
- Query chaincode.
- Invoke chaincode.
- Query chaincode again, to make sure invoking is the success.
To Get more information about Hyperledger Fabric Go SDK, please refer to: fabric-sdk-go.