go新环境Mac安装,包含okexchain
在一台全新的Mac电脑上搭建go环境:
2022.11.1
最简单的办法,下载pkg文件,双击安装。
如果以前有,可 rm -rf /usr/loca/go 删除。
1,下载go安装包
https://studygolang.com/dl # 中文网
https://golang.org/doc/install #官网
2,配置go path
$ go env
GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/Users/oker/Library/Caches/go-build" GOENV="/Users/oker/Library/Application Support/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOINSECURE="" GOMODCACHE="/Users/oker/go/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="darwin" GOPATH="/Users/oker/go" # 编写代码存放的目录 GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/usr/local/go" # go安装的路径 GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64" GOVCS="" GOVERSION="go1.16.3" GCCGO="gccgo" AR="ar" CC="clang" CXX="clang++" CGO_ENABLED="1" GOMOD="/dev/null" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/h8/9n_7qfp153g3q8_jpb43hn2h0000gn/T/go-build397154971=/tmp/go-build -gno-record-gcc-switches -fno-common"
$ go version
go version go1.16.3 darwin/amd64
在 ~ 下
mkdir go
cd go
mkdir bin src pkg
vim ~/.zshrc
export GOPATH="/Users/oker/go"
此行的作用是告诉go,你的代码目录。
默认情况下我没有.zshrc文件,所以这里执行了:https://www.cnblogs.com/zccst/p/14633665.html
3,下载goland
4,编译okexchain
export GO111MODULE=on
export GOPROXY="https://goproxy.io"
make GenesisHeight=1121818 install
生成了okexchaind和okexchaincli,但不生效。
# 再次修改环境变量
vim ~/.zshrc
export GOPATH="/Users/oker/go"
export GOBIN="${GOPATH}/bin"
export PATH=$PATH:/usr/local/go/bin:$GOBIN