2017-08-08 08:55:34

windows子系统下安装go语言环境

windows子系统下安装go语言环境

https://storage.googleapis.com/golang

  1. 安装指定版本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
  1. 新建gopath 目录
mkdir /opt/go
  1. 设置所有用户环境变量,打开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
  1. 让设置生效
source /etc/profile
  1. 查看是否安装成功
go version

go env
  1. 安装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

本文链接:https://blog.zxysilent.com/post/win-sub-sys-go.html

-- EOF --