Home > Categories > Ubuntu > How to Install or Update Golang in Ubuntu
Home > How to Install or Update Golang in Ubuntu
How to Install or Update Golang in Ubuntu
Updated:
Published:
I always used brew
package manager for installing golang but one time something crashed and I could not use golang anymore.
The error wouldn't go away by reinstalling golang with brew.
I tried uninstalling then restarting computer and then installing again. The error persisted.
Then I had to manually install golang. Also since I switched to ARM Ubuntu I started installing all packages manually. So lets get started.
To read rest of the article please Purchase Subscription
First step is to create new folder with any name of your choice. This is where you download/extract/build packages.
So in case you mess things up and extract 3000 random files then you can just delete the whole folder and not mess with your existing files.
I always name it download. The name is based on download folder used in either Windows or macOS.
mkdir download
cd download
Now go to official golang download page and copy link of file you want to download.
The file would depend on your operating system and type of cpu you are using (arm/x86). Then download the file as follows
wget insert_download_url_here
for example
wget https://golang.org/dl/go1.15.5.linux-arm64.tar.gz
Now we also need to verify the checksum. This verifies that the file was not modified while download. So create a new file
vi checksum.txt
Then press i and add the file name and its checksum as follows
|
|
Then save the file with escape :wq
. This will write the file and quit.
Then verify the checksum with following command
sha256sum --check checksum.txt
The above command will create output like following
go1.15.5.linux-arm64.tar.gz: OK
Ok means file is original and unmodified.
Then extract the compressed file with following command
tar -xf name_of_compressed_file
For example
tar -xf go1.15.5.linux-arm64.tar.gz
-x
= Extract
-f
= Specified file name
Then move the extracted folder
sudo mv go/ /usr/local/
Then you need to add go path
vi ~/.profile
Add following at the bottom of the profile
|
|
Then refresh profile and check go version
. ~/.profile
go version
You will see output like follows.
go version go1.15.5 linux/arm64
For updating the steps are exactly the same except you don't have to add the path.
You delete previous go folder and replace with new one.
Free users cannot comment below so if you have questions then tweet me @apoorvmote. I would really like to hear your brutally honest feedback.
If you like this article please consider purchasing paid