25.1 C
Senior Writer and partner

How to install Go programming language on OpenSUSE 15.2?

OpenSUSE is a great operating system that comes from the hand of SUSE. That’s why it’s a good target for developers all over the world. Also because it is robust and has great support for languages like Go. So in this post, you can learn how to install Go programming language on OpenSUSE 15.2.

Go is an open-source (BSD license) programming language that was born with the objective of allowing the creation of efficient and easily distributable applications. So, it has binaries for Windows, Mac OS, and of course, for Linux.

Install Go programming language on OpenSUSE 15.2

As I mentioned before, OpenSUSE provides great support for different popular languages through a dedicated repository. This repository is not activated but it is very easy to do.

With this repository, we will get recent versions of many programming languages and among them Go.

- Advertisement -

So, open a terminal and run the following command:

sudo zypper -ar https://download.opensuse.org/repositories/devel:/languages:/go/openSUSE_Leap_15.2/ devel

OpenSUSE manages the repositories according to the priority they have. The lower the first one is, So the newly added repository has to be reprioritized.

sudo zypper mr -p 70 devel

This ensures that we will always get updates from this repository. Now we have to refresh Zypper’s cache to accept the repository’s GPG key.

sudo zypper refresh
Retrieving repository 'devel' metadata -------------------------------------------------------------------------------------------------------------------------------[/]
New repository or package signing key received:
Repository: devel
Key Name: devel:languages:go OBS Project
Key Fingerprint: B619E7E2 4D0ED061 FA14343C AF4CFE4D 307D7BF9
Key Created: Wed Jun 3 00:52:51 2020
Key Expires: Fri Aug 12 00:52:51 2022
Rpm Name: gpg-pubkey-307d7bf9-5ed72ca3
Do you want to reject the key, trust temporarily, or trust always? r/t/a/?:

Later we can install Go. At the time of writing is the post the last stable version is 1.15.2

sudo zypper in go1.15
Loading repository data…
Reading installed packages…
Resolving package dependencies…
The following 17 NEW packages are going to be installed:
gcc gcc7 glibc-devel go1.15 go1.15-doc go1.15-race libasan4 libatomic1 libcilkrts5 libgomp1 libitm1 liblsan0 libmpx2 libmpxwrappers2 libtsan0 libubsan0
The following recommended package was automatically selected:
17 new packages to install.
Overall download size: 141.7 MiB. Already cached: 0 B. After the operation, additional 614.1 MiB will be used.
Continue? y/n/v/…? shows all options:

Now we can check the operation of the command Go, showing the installed version.

go version
go version go1.15.2 linux/amd64

Now we will create the first program.

The Hello World on Go

The first thing we have to do is create a folder for all our projects with Go. This folder can be in any location.

mkdir go_projects

The following is to add some environment variables to the system configuration. To do this, you must edit the file /etc/profile and add the following lines:

export GOPATH=$HOME/go_projects
export GOBIN=$GOPATH/bin

Replace the value of GOPATH with the path of the folder created for Go projects.

Save the changes and close the editor.

To create the first program, we have to create inside the project folder a folder called src and inside another folder with the name of our program.

For example:

mkdir -p ~/go_projects/src/first_program

Now access your program folder. In this case, it is “first_program“.

cd ~/go_projects/src/first_program

And create the source file with extension go.

nano ~/go_projects/src/first_program/helloworld.go

And start creating code. In our test case, we’ll just do a hello world.

package main
import "fmt"
func main() {
fmt.Printf("Welcome To 2daygeek\n")
1.- Hello world program with Go on OpenSUSE 15.2
1.- Hello world program with Go on OpenSUSE 15.2

Save the changes and close the editor.

Now compile the program:

go build first_program
go install first_program

This will generate a binary that we can execute:



Welcome Osradar
2.- Go working properly
2.- Go working properly

And this way it is possible to get Go on OpenSUSE 15.2


GO is a very popular language and every day it is more and more popular. It’s simple but very powerful, besides being open source. As you have seen, its installation is really simple.

Please share this article on your social networks. Also, join our Telegram Channel and buy us a coffee. Also, visit our Facebook page.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
"The best Linux newsletter on the web"



Please enter your comment!
Please enter your name here

Latest article