下载golang安装包(注意和源码包的区别,源码包不含有bin目录)
wget -c https://studygolang.com/dl/golang/go1.13.4.linux-amd64.tar.gz
解压生成/usr/local/go($GOROOT)目录
tar -C /usr/local -xzfgo1.13.4.linux-amd64.tar.gz
创建gopath($GOPATH)目录
mkdir -p /usr/local/gopath
编辑go env相关环境变量
vim /etc/profile
export GOROOT=/usr/local/go
exportGOPATH=/usr/local/gopath
exportPATH=$PATH:$GOROOT/bin:$GOPATH/bin
source /etc/profile
go version
go env
手动下载依赖包,处理GFW屏蔽问题
对于常用的涉及golang.org/x/foobar的依赖包,
手动下载对应的github.com/golang/foobar到$GOPATH/src/golang.org/x目录下:
git clonehttps://github.com/golang/net.git $GOPATH/src/golang.org/x/net
git clonehttps://github.com/golang/text.git $GOPATH/src/golang.org/x/text
git clonehttps://github.com/golang/tools.git $GOPATH/src/golang.org/x/tools
git clonehttps://github.com/golang/lint.git $GOPATH/src/golang.org/x/lint
git clonehttps://github.com/golang/crypto.git $GOPATH/src/golang.org/x/crypto
git clone https://github.com/golang/sys.git$GOPATH/src/golang.org/x/sys
git clonehttps://github.com/grpc/grpc-go.git $GOPATH/src/google.golang.org/grpc
git clonehttps://github.com/google/go-genproto.git$GOPATH/src/google.golang.org/genproto
git clonehttps://github.com/golang/protobuf.git $GOPATH/src/github.com/golang/protobuf
拿grpc测试一下:
cd $GOPATH/src
go install google.golang.org/grpc
go rungoogle.golang.org/grpc/examples/helloworld/greeter_server/main.go
go rungoogle.golang.org/grpc/examples/helloworld/greeter_client/main.go
设置代理,处理GFW屏蔽问题
可参考https://github.com/goproxy、https://goproxy.io
执行go env -w GOPROXY=https://goproxy.cn即可,执行go
env查看。
下载go-ethereum源码,并编译生成可执行文件
git clone https://gitee.com/mirrors/go-ethereum.git(下载速度更快)
git clone https://github.com/ethereum/go-ethereum
cd go-ethereum
make geth 或者make all
ls build/bin,可以看到可执行文件:
abigen checkpoint-admin devp2pevm faucet p2psim rlpdump
bootnode clef ethkey examples gethpuppet wnode
来源:oschina
链接:https://my.oschina.net/u/2277392/blog/3191557