Go编译器开发环境搭建(源码构建)

  • 源码编译
# 克隆go源码
git clone https://gitee.com/unize4/go.git goroot  # 镜像地址
# 编译配置bootstrap go版本
cd goroot
git checkout release-branch.go1.4
cd .. && cp -rf goroot go1.4
cd go1.4/src
./all.bash
cd .. 
export GOROOT_BOOTSTRAP=$(pwd)  # GOROOT_BOOTSTRAP=~/go.14
# 编译目标版本
cd ../goroot
git checkout release-branch.go1.14
cd src && ./all.bash
  • 设置环境变量
export GOROOT_BOOTSTRAP=~/go.14
export GOROOT=~/goroot
export GOPATH=~/gopath
export PATH=${PATH}:${GOROOT}/bin:${GOPATH}/bin # goroot放在gopath前面
  • 测试
# 打开新的bash
which go
go version
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。