A lot’s of people confused on how to setup golang properly so I’m here to help you get started !!!
Go to this website: https://go.dev/dl/
This is the official go language website. If you’re using Kali or any Linux system look for the newest ‘linux-amd64.tar.gz’ version and copy the link.
I am choosing 1.22.6 right now this is the latest version so follow this commands:
Following command is downloading the zip file in your current directory.
wget
is a command-line utility for downloading files from the internet
wget https://go.dev/dl/go1.22.6.linux-amd64.tar.gz
Following command is copy the downloaded go lang zip file in /usr/local/bin/
cp go1.22.6.linux-amd64.tar.gz /usr/local/bin/
tar is a tool which extracts the zip file
-C changes the directory before performing unzip
-xzf is extract while decompressing using gzip format
tar -C /usr/local/ -xzf /usr/local/bin/go1.22.6.linux-amd64.tar.gz
Following command is for editing the .bashrc file of the current user
nano ~/.bashrc
Add the following command to .bashrc in the last line.
export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin
Following command reloads the .bashrc file into the current shell session, applying the changes you made. The newly added environment variables (GOROOT and the updated PATH) take effect immediately.
source ~/.bashrc
After that check the go version using the following command
go version