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 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路径可卸载之前的一样
|
请发表评论