This SDK enables Go developers to build solutions that interact with Hyperledger Fabric.
Obtain the client SDK packages for Fabric and Fabric CA.
# Hyperledger Fabric client package
go get -u github.com/hyperledger/fabric-sdk-go/pkg/fabric-client
# Hyperledger Fabric CA client package
go get -u github.com/hyperledger/fabric-sdk-go/pkg/fabric-ca-client
You're good to go, happy coding! Check out the examples for usage demonstrations.
- E2E Test and Base Test: Part of the E2E tests included with the Go SDK.
- CLI: An example CLI for Fabric built with the Go SDK.
- More examples needed!
- Discussion is happening in Rocket Chat.
- Issue tracking is handled in Jira.
- Active development occurs in the Gerrit repository.
This client SDK was last tested and found to be compatible with the following Hyperledger Fabric commit levels:
- fabric: v1.0.0
- fabric-ca: v1.0.0
# In the Fabric SDK Go directory
cd $GOPATH/src/github.com/hyperledger/fabric-sdk-go/
# Running test suite
make
# Clean test suite run artifacts
make clean
If you want to contribute to the Go SDK, please run the test suite and submit patches to the Gerrit git repostory for review. For general guidelines, please refer to the Fabric project's contribution page.
You need:
- Go
- Make
- Docker
- Docker Compose
- Git
To contribute patches, you will need to clone (or add a remote) from Gerrit with authentication.
# In the Fabric SDK Go directory
cd $GOPATH/src/github.com/hyperledger/fabric-sdk-go/
# Ensure dependencies are installed
make depend
# Running code checks (license, linting, spelling, etc)
make checks
# Running all unit tests
make unit-test
# Running all integration tests
make integration-test
# In a package directory
go test
You need:
- A working fabric and fabric-ca set up. It is recommended that you use the docker-compose file provided in
test/fixtures
. It is also recommended that you use the default .env settings provided intest/fixtures
. See steps below. - Customized settings in the
test/fixtures/config/config_test.yaml
in case your Hyperledger Fabric network is not running onlocalhost
or is using different ports.
Testing with Fabric Images at Docker Hub
The test suite defaults to the latest compatible tag of fabric images at Docker Hub. The following commands starts Fabric:
# In the Fabric SDK Go directory
cd $GOPATH/src/github.com/hyperledger/fabric-sdk-go/
# Clean previous test run artifacts
make clean
# Start fabric
cd $GOPATH/src/github.com/hyperledger/fabric-sdk-go/test/fixtures/
docker-compose up --force-recreate
Running Integration Tests
Fabric should now be running. In a different shell, run integration tests
# In the Fabric SDK integration tests directory
cd $GOPATH/src/github.com/hyperledger/fabric-sdk-go/test/integration/
go test
Testing with Local Build of Fabric (Advanced)
Alternatively you can build and run Fabric on your own box using the following commands:
# Build fabric:
cd $GOPATH/src/github.com/hyperledger/
git clone https://github.com/hyperledger/fabric
cd $GOPATH/src/github.com/hyperledger/fabric/
git checkout v1.0.0
make docker
# Build fabric-ca:
cd $GOPATH/src/github.com/hyperledger/
git clone https://github.com/hyperledger/fabric-ca
cd $GOPATH/src/github.com/hyperledger/fabric-ca/
git checkout v1.0.0
make docker
# Start fabric - latest-env.sh overrides the default docker tags in .env
cd $GOPATH/src/github.com/hyperledger/fabric-sdk-go/test/fixtures/
(source latest-env.sh && docker-compose up --force-recreate)
Hyperledger Fabric SDK Go software is licensed under the Apache License Version 2.0.
This document is licensed under a Creative Commons Attribution 4.0 International License.