Linux and Windows tutorials and guides
Golang, commonly known as Go, is a powerful programming language developed by Google. It is renowned for its simplicity, efficiency, and strong support for concurrent programming. If you’re looking to harness the capabilities of Go on a Linux system, this guide will walk you through the installation process step-by-step.
Step 1: Update Your System
Before installing any new software, it’s always a good idea to update your system’s package list and upgrade any outdated packages. Open your terminal and execute the following commands:
sudo apt update
sudo apt upgrade
Step 2: Download Go
Visit the official Go programming language website to download the latest version. Alternatively, you can use wget
in the terminal. Run the following command to download the latest version (replace 1.23.5
with the current version):
wget https://go.dev/dl/go1.23.5.linux-amd64.tar.gz
Step 3: Extract the Archive
Once the download is complete, you need to extract the tarball. Use the following command:
sudo tar -C /usr/local -xzf go1.23.5.linux-amd64.tar.gz
This command extracts Go into the /usr/local
directory, which is the standard location for user-installed software on Linux.
Step 4: Set Up the Environment Variables
To use Go from the terminal, you need to set up the environment variables. Open your .bashrc
or .profile
file in a text editor:
nano ~/.bashrc
Add the following lines at the end of the file:
export PATH=$PATH:/usr/local/go/bin
Save the file and exit the editor. To apply the changes, run:
source ~/.bashrc
Step 5: Verify the Installation
To ensure that Go is installed correctly, check the version by running:
go version
You should see output similar to: Copy
go version go1.23.5 linux/amd64
This confirms that Go is installed and ready to use.
Step 6: Set Up Your Go Workspace
Go uses a workspace structure to manage code. You can create your Go workspace by executing the following commands:
mkdir -p ~/go/{bin,src,pkg}
Next, you need to set the GOPATH
environment variable. Again, open your .bashrc
file:
nano ~/.bashrc
Add the following line:
export GOPATH=$HOME/go
Save the file and apply the changes:
source ~/.bashrc
Conclusion
You have successfully installed Go on your Linux system! With Go set up, you can start exploring its features and building your applications. Whether you are developing web servers, command-line tools, or microservices, Go provides the performance and simplicity you need.
Feel free to dive into the official Go documentation for more resources and tutorials.