Goland 升级

既是升级也是安装。

卸载旧版本Goland

1
2
3
4
sudo rm -rf /usr/local/go
sudo apt-get remove golang
sudo apt-get remove golang-go
sudo apt-get autoremove

1. 获取最新版本Goland

根据环境配置选择对应的Goland安装包。

1
wget https://golang.google.cn/dl/go1.25.6.linux-amd64.tar.gz

2. 解压安装包

下载到当前目录,解压到 /usr/local 目录

1
tar -C /usr/local -zxvf go1.19.linux-amd64.tar.gz

3. 添加bin命令到环境变量

  • /etc/profile: root 用户可修改,作用全局​​(对所有用户生效)
  • $HOME/.profile: 当前用户可修改,作用个人(仅对当前用户生效)
1
2
3
4
5
6
cat >> /etc/profile <<EOF
export GOROOT=/usr/local/go
export GOPATH=$HOME/gowork
export GOBIN=$GOPATH/bin
export PATH=$GOPATH:$GOBIN:$GOROOT/bin:$PATH
EOF

环境变量保存退出,需要source更新下

1
source /etc/profile

4. 查看goland状态

1
2
3
4
# 查看版本
go version
# 查看goland环境
go env

alt text

5. 设置七牛云代理(推荐)

1
2
3
4
5
6
cat >> /etc/profile <<EOF
export GO111MODULE=on
export GOPROXY=https://goproxy.cn
EOF

source ~/.profile

6. 特别注意:环境变量已就位,但Shell不生效

确认自己使用的终端,Linux默认bash。

  • Bash 用户:通常会读取 /etc/profile -> /etc/profile.d/*.sh。
  • Zsh 用户:默认读取的是 ~/.zshenv -> ~/.zshrc -> ~/.zprofile。