{"id":13856,"date":"2024-05-28T20:10:03","date_gmt":"2024-05-28T17:10:03","guid":{"rendered":"http:\/\/local.brightwhiz\/?p=13856"},"modified":"2024-05-28T20:10:04","modified_gmt":"2024-05-28T17:10:04","slug":"a-comprehensive-guide-to-installing-go-golang-on-ubuntu-24-04-22-04-and-20-04-linux-systems","status":"publish","type":"post","link":"http:\/\/local.brightwhiz\/a-comprehensive-guide-to-installing-go-golang-on-ubuntu-24-04-22-04-and-20-04-linux-systems\/","title":{"rendered":"A Comprehensive Guide to Installing Go (Golang) on Ubuntu 24.04, 22.04, and 20.04 Linux Systems"},"content":{"rendered":"\n
Go, also known as Golang, is a powerful, efficient, and statically typed programming language developed by Google. It\u2019s well-suited for building reliable and efficient software. Whether you’re developing web applications, microservices, or system tools, Go’s simplicity and performance make it a popular choice. This guide will walk you through the steps to install Go<\/a> on Ubuntu<\/a> 24.04, 22.04, and 20.04 systems.<\/p>\n\n\n\n Go is designed for simplicity, concurrency, and performance. It compiles to machine code, has garbage collection, and provides robust concurrency mechanisms. These features make it an excellent choice for developers looking for a balance between speed and ease of use.<\/p>\n\n\n\n Before starting the installation, ensure you have the following:<\/p>\n\n\n\n First, download the latest Go binary from the official Go website. You can use To ensure the integrity of the downloaded file, you can verify it using the SHA256 checksum. First, download the checksum file from the Go website, then use the Compare the output with the checksum provided on the Go download page.<\/p>\n\n\n\n Next, extract the tarball to the To make Go available system-wide, you need to add the Go binary to your Open the profile file with your preferred text editor:<\/p>\n\n\n\n Add the following lines to the end of the file:<\/p>\n\n\n\n Save and close the file, then reload the profile to apply the changes:<\/p>\n\n\n\n Verify that Go is installed correctly by checking the version:<\/p>\n\n\n\n You should see output similar to:<\/p>\n\n\n\n Go encourages a specific workspace structure. By default, Go looks for its workspace under Add the workspace directory to your Add the following line:<\/p>\n\n\n\n Save and close the file, then reload the profile:<\/p>\n\n\n\n Congratulations! You have successfully installed Go (Golang) on your Ubuntu 24.04, 22.04, or 20.04 system. You are now ready to start developing applications using Go\u2019s powerful and efficient features. Happy coding!<\/p>\n\n\n\nWhy Choose Go?<\/strong><\/h3>\n\n\n\n
Prerequisites<\/strong><\/h3>\n\n\n\n
\n
Step-by-Step Installation Guide<\/strong><\/h2>\n\n\n\n
Step 1: Download the Go Binary<\/h3>\n\n\n\n
wget<\/code> to download the file directly to your system. As of this writing, the latest stable version is 1.20. If there is a newer version, replace the version number in the URL.<\/p>\n\n\n\n
$ wget https:\/\/golang.org\/dl\/go1.20.linux-amd64.tar.gz<\/code><\/pre>\n\n\n\n
Step 2: Verify the Download (Optional)<\/h3>\n\n\n\n
sha256sum<\/code> command:<\/p>\n\n\n\n
$ sha256sum go1.20.linux-amd64.tar.gz<\/code><\/pre>\n\n\n\n
Step 3: Extract the Archive<\/h3>\n\n\n\n
\/usr\/local<\/code> directory. This is the recommended location for Go installations:<\/p>\n\n\n\n
$ sudo tar -C \/usr\/local -xzf go1.20.linux-amd64.tar.gz<\/code><\/pre>\n\n\n\n
Step 4: Set Up the Go Environment<\/h3>\n\n\n\n
PATH<\/code>. You can do this by editing your shell profile file. For Bash, this file is typically
.bashrc<\/code> or
.profile<\/code>. For Zsh, it\u2019s
.zshrc<\/code>.<\/p>\n\n\n\n
$ nano ~\/.bashrc<\/code><\/pre>\n\n\n\n
$ export PATH=$PATH:\/usr\/local\/go\/bin<\/code><\/pre>\n\n\n\n
$ source ~\/.bashrc<\/code><\/pre>\n\n\n\n
Step 5: Verify the Installation<\/h3>\n\n\n\n
$ go version<\/code><\/pre>\n\n\n\n
$ go version go1.20 linux\/amd64<\/code><\/pre>\n\n\n\n
Step 6: Set Up Your Go Workspace<\/h3>\n\n\n\n
~\/go<\/code>. You can set this up by creating the necessary directories:<\/p>\n\n\n\n
$ mkdir -p ~\/go\/{bin,src,pkg}<\/code><\/pre>\n\n\n\n
GOPATH<\/code>. Again, open your profile file:<\/p>\n\n\n\n
$ nano ~\/.bashrc<\/code><\/pre>\n\n\n\n
$ export GOPATH=$HOME\/go\nexport PATH=$PATH:$GOPATH\/bin<\/code><\/pre>\n\n\n\n
$ source ~\/.bashrc<\/code><\/pre>\n\n\n\n
Conclusion<\/h3>\n\n\n\n