How to install golang on ubuntu
Hello Everyone in this post I will save my little note about how to install golang on ubuntu.What is golang ?. Go-language or Go is a programming language created by Google around 2007. This language is also popularly used by many applications such as Docker, Kubernetes, etc.
Check ubuntu version
Before we install i always check my linux version
lsb_release -a
output:
// Output
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.1 LTS
Release: 18.04
Codename: bionic
1. Install via apt-get
Open your terminal
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install golang-go
After that check Go version
go version
Output:
go version
2. Install via binary distribution
Let’s start install golang. First open the web go with this url https://golang.org/dl/ and select the release that is compatible with your OS.
go1.23.0.linux-amd64.tar.gz
Now Open your terminal, download and extract in the current folder.
wget https://dl.google.com/go/go1.13.1.linux-amd64.tar.gz
sudo tar -xvf go1.13.1.linux-amd64.tar.gzz
Now we have a folder called /go in the current directory location. Move the location to /usr/local/.
sudo mv go /usr/local
Set Environment
And the last step is to add it to the global variable via the .bashrc or .profile file. if you are confused, look for the .bashrc or .profile file in your home folder /home click view -> show hidden files
Just open it, you’re free to use any editor, the important thing is you have to Open as root or use the terminal, type like this.
sudo nano ~/.bashrc
Scroll down and add the last line like this.
or if you use the terminal just type.
# Go Global variables
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
don’t forget to save. Update the current session by loading the config we just changed with the command.
source ~/.bashrc
Check Go Version
Let’s check Go version
go version
Output:
// Output
go version go1.23.0 linux/amd64
ok everything is done