Linux upgrade version at golang

In most cases, are installed in the server go go1.6.2 this version, for some projects do not meet the requirements. So we need to be manually updated version golang.

1. Check the version golang

root@ubuntu:/home/liu# go version
go version go1.6.2 linux/amd64

2. Download the corresponding version of the required files from the Internet

Download link , here I've finished downloading
Here Insert Picture Description

3. Extract golang package

tar -zxvf go1.13.8.linux-amd64.tar.gz

Recompression After completing the package directory will be more of a go folders, directories, here is my /usr/localnext

4. Review the information on the original golang of env

go env

Here Insert Picture Description
We can see GOROOT="/usr/lib/go-1.6", that is the location where the original golang, we enter the / usr / lib directory

cd /usr/lib/

View all documents (option al can show the address pointed to by the soft link file):

ls -al

Here Insert Picture Description
We can find, go the soft link file points to go-1.6 folder, which is the original golang source folder. If we replace the version, which is the replacement of the go-1.6, we have to change this soft link to the address at the same time.

5. Modify the environment variables GOROOT

vim /etc/profile

Then in the final document by adding the following two sentences:

export GOROOT="/usr/local/go"
export PATH=$PATH:$GOROOT/bin

Use the source command allows to modify the configuration to take effect:

source /etc/profile

5. Modify go soft link address

在这里插入代码片

Then go see the link address again:

ls -al

Here Insert Picture Description
Can be found, go the link address has been modified

6. Verify whether the modified version of the successful

Here Insert Picture Description
It should be noted that, if done the steps above, go version or not modified, the proposed restart the computer, or check back later on command, or multi-source several times.

Published 40 original articles · won praise 7 · views 9998

Guess you like

Origin blog.csdn.net/weixin_44617722/article/details/104947835