linux下go安装/卸载重装

go安装

下载

首先,在官网下载最新版本官网download
选择linux,进入下载页面下载
根据页面的安装指引,将go文件夹解压到/usr/local/文件夹下
tar -C /usr/local -xzf go1.12.7.linux-amd64.tar.gz

配置环境变量:

将 /usr/local/go/bin 添加到Path的环境变量里
修改/etc/profile文件
添加
export GOROOT=/usr/local/go
export GOPATH=/data/cuteFiles/go
export PATH=$PATH:$GOROOT/bin
执行go env就可以查看go的一些参数
go 相关参数值
可以自己写一个小代码运行测试一下

go卸载重装(升级版本)

跟go安装的区别就是,需要卸载。
可以执行go env查看GOROOT
我这里GOROOT=/usr/local/go,进入/usr/local,删除go文件夹
命令:sudo rm -rf /usr/local/go

官网原话:
[1]To remove an existing Go installation from your system delete the go directory. This is usually /usr/local/go under Linux, macOS, and FreeBSD or c:\Go under Windows.
[2]You should also remove the Go bin directory from your PATH environment variable. Under Linux and FreeBSD you should edit /etc/profile or $HOME/.profile. If you installed Go with the macOS package then you should remove the /etc/paths.d/go file. Windows users should read the section about setting environment variables under Windows.

因为要重装的话,就不需要将GOROOT/bin从path里删除了,还省去了配置/etc/profile,但前提是新安装的go路径可卸载之前的一样

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值