windows子系统下安装go语言环境
https://storage.googleapis.com/golang
- 安装指定版本Golang
rm -rf /usr/local/go && curl -L https://dl.google.com/go/go1.22.7.linux-amd64.tar.gz | tar -C /usr/local -xzf - && go version
- 新建
gopath
目录
mkdir /opt/go
- 设置所有用户环境变量,打开
vim etc/profile
文件最后添加
export GOROOT=/usr/local/go
export GOPATH=/opt/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
export GO111MODULE=on
export GOPROXY=https://goproxy.cn,direct
- 让设置生效
source /etc/profile
- 查看是否安装成功
go version
go env
- 安装
git
sudo apt-get install git git-core
rm -rf /usr/local/go && curl -L https://dl.google.com/go/go1.22.7.linux-amd64.tar.gz | tar -C /usr/local -xzf - && go version
mkdir /opt/go
#\EOF 禁止 $PATH转义
cat << \EOF >> /etc/profile
export GOROOT=/usr/local/go
export GOPATH=/opt/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
export GO111MODULE=on
export GOPROXY=https://goproxy.cn,direct
EOF
source /etc/profile
go version
rm -rf /usr/local/go && curl -L https://dl.google.com/go/go1.22.7.linux-amd64.tar.gz | tar -C /usr/local -xzf - && go version