安装go
wget https://storage.googleapis.com/golang/go1.8.3.linux-amd64.tar.gz
tar -xvf go1.8.3.linux-amd64.tar.gz
mv go /usr/local/
mkdir -p /root/golang
vim /etc/profile
export GOPATH=/root/golang
export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
source /etc/profile
为解决fabric编译报错:can't load package: package github.com/hyperledger/fabric/peer: open /opt/gopath/src/github.com/hyperledger/fabric/peer: permission denied
ln -s $GOPATH /opt/gopath
安装依赖包
apt-get update
apt-get install -y libsnappy-dev zlib1g-dev libbz2-dev libltdl-dev libtool
安装docker
curl -fsSL https://get.docker.com/ | sh
安装docker-compose(本节暂时未用到)
pip install docker-compose
Fabric源码下载
git clone https://github.com/hyperledger/fabric $GOPATH/src/github.com/hyperledger/fabric
git clone https://github.com/hyperledger/fabric-ca $GOPATH/src/github.com/hyperledger/fabric-ca
或
go get github.com/hyperledger/fabric
go get github.com/hyperledger/fabric-ca
编译fabric代码
cd $GOPATH/src/github.com/hyperledger/fabric
make native
make docker
cp build/bin/* $GOPATH/bin/
解决编译fabric过程中报错
如下为解决:package golang.org/x/tools/go/gcexportdata: unrecognized import path "golang.org/x/tools/go/gcexportdata"
git clone https://github.com/golang/tools.git $GOPATH/src/golang.org/x/tools
如下为解决:cp: cannot stat ‘build/docker/gotools/bin/protoc-gen-go’: No such file or directory
go get github.com/golang/protobuf/protoc-gen-go
cd $GOPATH/src/github.com/golang/protobuf/
make all
cd $GOPATH/src/github.com/hyperledger/fabric
cp $GOPATH/bin/protoc-gen-go build/docker/gotools/bin/
如下为解决:./scripts/golinter.sh: line 28: goimports: command not found
apt install golang-golang-x-tools
编译fabric-ca代码
cd $GOPATH/src/github.com/hyperledger/fabric-ca
make docker
有疑问加站长微信联系(非本文作者)