openSUSE

How To Install Go on openSUSE

Install Go on openSUSE

In this tutorial, we will show you how to install Go on openSUSE. Go, also known as Golang, is an open-source programming language created by Google in 2007. It was designed to be simple, efficient, and easy to learn, with a focus on concurrency and performance. Its unique features like an intuitive concurrency model and opinionated approach to problems like error handling make it a compelling option in the modern programming landscape.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the Go (Golang) programming language on openSUSE.

Prerequisites

  • A server running one of the following operating systems: openSUSE (Leap or Tumbleweed)
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • You will need access to the terminal to execute commands. openSUSE provides the Terminal application for this purpose. It can be found in your Applications menu.
  • You’ll need an active internet connection to download Go (Golang) and its dependencies.
  • You’ll need administrative (root) access or a user account with sudo privileges.

Install Go on openSUSE

Step 1. It’s also essential to ensure that your system is up-to-date. To update your openSUSE system, open a terminal and run the following command:

sudo zypper refresh
sudo zypper update

Step 2. Installing Go (Golang) on openSUSE.

Visit the official Go downloads page and copy the download link for the latest version of Go for Linux. In a terminal, use the wget command to download the archive:

wget https://go.dev/dl/go1.22.1.linux-amd64.tar.gz

After the download is complete, verify the integrity of the downloaded archive using the provided SHA256 checksum:

sha256sum go1.22.1.linux-amd64.tar.gz

Compare the output with the official checksum value provided on the Go downloads page.

Once the download is verified, extract the archive using the tar command:

sudo tar -C /usr/local -xzf go1.22.1.linux-amd64.tar.gz

This will extract the Go files to the /usr/local/go directory.

Step 3. Configure Go Environment Variables.

To use Go from the command line, you need to configure the environment variables. Open your shell configuration file (e.g., ~/.bashrc for Bash or ~/.zshrc for Zsh) using a text editor:

nano ~/.bashrc

Add the following lines to the file:

export PATH=$PATH:/usr/local/go/bin
export GOROOT=/usr/local/go

Save and close the file. Then, source the configuration file to apply the changes:

source ~/.bashrc

Step 4. Create a Go Workspace.

Go expects your code to be organized in a specific workspace structure. Create a new directory for your Go workspace and set the GOPATH environment variable:

mkdir ~/go
export GOPATH=$HOME/go

You can add the GOPATH variable to your shell configuration file (~/.bashrc or ~/.zshrc) for persistent configuration.

After completing the above steps, verify the installed Go version by running:

go version

Step 5. Write and Run a Sample Go Program.

To ensure that Go is properly installed and configured, you can write and run a simple Go program. Create a new file called hello.go in your Go workspace’s src directory ($GOPATH/src):

package main

import "fmt"

func main() {
    fmt.Println("Hello, openSUSE!")
}

Save the file and navigate to the directory containing hello.go. Then, run the program using the go run command:

go run hello.go

Congratulations! You have successfully installed Go. Thanks for using this tutorial for installing the Go (Golang) programming language on your openSUSE system. For additional or useful information, we recommend you check the official Go website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button