Home > Backend Development > Golang > How to upgrade the go language version

How to upgrade the go language version

王林
Release: 2023-01-11 09:23:19
Original
15176 people have browsed it

go语言升级版本的方法:1、在官网下载最新的源码包;2、将源码包放在相应目录下;3、运行【sh install.sh go1.xx.linux-amd64.tar.gz】命令即可。

How to upgrade the go language version

本文操作环境:windows10系统、GO 1.11.2、thinkpad t480电脑。

(学习视频分享:编程视频

安装步骤:

第一步:到官网上下载对应的操作系统的最新的 Golang 版本:https://studygolang.com/dl

在 home 目录下建立 goinstall 目录,然后在该目录下创建升级部署文件以及下载最新的 golang 源码:

How to upgrade the go language version

以下是 install.sh 具体内容:

#!/bin/bash
if [ -z "$1" ]; then
        echo "usage: ./install.sh go-package.tar"
        exit
fi

if [ -d "/usr/local/go" ]; then
        echo "Uninstalling old version..."
        sudo rm -rf /usr/local/go
fi
echo "Installing..."
sudo tar -C /usr/local -xzf $1
echo "Done"
Copy after login

然后运行:

sh install.sh go1.10.linux-amd64.tar.gz
Copy after login

第二步:设置好 GOPATH,GOROOT

编辑 /etc/profile 在文件尾部加入:

export GOPATH=/go
export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
Copy after login

然后运行 source /etc/profile 让环境变量生效

至此,Golang 版本已安装成功。

升级版本:

如果需要升级的话只需要将最新的源码包下载到第一步的 goinstall 文件下,然后运行sh install.sh go1.xx.linux-amd64.tar.gz 即可。

相关推荐:golang教程

The above is the detailed content of How to upgrade the go language version. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template