Mac源码安装go1.18
1、更新brew
Brew update
2、安装go@1.17版本,用来源码编译1.18
Brew install go@1.17

3、 下载源码
Git clone https://github.com/golang/go

4、进入go文件夹
Cd go
5、 切换到1.18分支
git checkout release-branch.go1.18
6、 编译go

Cd src
./make.bash

7、 卸载1.17版本
brew uninstall go

8、添加环境变量vim ~/.bash_profile
,加入如下几行 GO_INSTALL_DIR为下载go的目录
export PATH=$PATH:$GO_INSTALL_DIR/go/bin
export GOROOT= $GO_INSTALL_DIR/go
export GOBIN=$GOROOT/bin
export GOPATH= $GO_INSTALL_DIR/go/data
9、使配置生效
source ~/.bash_profile
10、检查版本
go version
有疑问加站长微信联系(非本文作者)
