如果存在使用apt安装的旧版golang,先卸载旧版程序
sudo apt-get remove golang-go

接着去官网下载最新版本的,下载地址:

https://golang.org/dl/

选择好须要安装的版本之后从Ubuntu上面下载该版本,这里我下载最新版本

wget https://golang.org/dl/go1.15.5.linux-amd64.tar.gz

然后解压压缩包到安装目录,这里我安装到 /opt 目录下面

tar -zxvf go1.15.5.linux-amd64.tar.gz -C /opt

接下来设置环境变量,编辑用户目录下面的.profile文件

cd ~/ && nano .profile

添加以下内容

export GOROOT=/opt/go              
export GOPATH=$HOME/go             
export GOBIN=$GOPATH/bin           
export PATH=$GOPATH:$GOBIN:$GOROOT/bin:$PATH 

GOROOT表示golang安装目录
GOPATH表示工作目录
GOBIN为可执行程序存放目录

.profile文件内容添加完之后使环境变量生效

source ~/.profile

最后测试是否安装成功,输入

go version

会显示

go version go1.15.5 linux/amd64

看到这里Ubuntu上面的golang就安装成功了

标签: ubuntu,golang,go

8条评论

  1. Link exchange is nothing else however it is simply placing the other person's webpage link on your page at proper place and other person will also do same in support of you.
  1. LGO4D adalah situs slot gacor terpercaya diantara agen 303 slot terbaik dan terbaru deposit pulsa pragmatic play yang sangat mudah menang di Indonesia
  1. Way cool! Some very valid points! I appreciate you penning this post and the rest of the site is extremely good.
  1. UICELL Conference Proceeding is published by University of Muhammadiyah Prof. DR. HAMKA (UHAMKA). p-ISSN: 2615-4269; e-ISSN: 2615-2576. It includes all papers presented at UICELL Conference. The articles in this electronic proceeding may have different format from the print versions. Each of the article is subject to minor spelling and grammatical error. Article copyright (c) rests on the authors.

添加新评论

  • 上一篇:
  • 下一篇: