Go, also known as Golang or Go language, is an open-source programming language developed by Google. It is a high-level language used for developing web applications, cloud, and networking services. Compared to other programming languages, Golang runs faster, compiles quicker, is easy to maintain and support, and allows for shorter software development lifecycles.

In this post, we will show you how to install Golang on Arch Linux.

Step 1 – Configure Repository

By default, the default repository is outdated in Arch Linux, so you will need to modify the default mirror list. You can do it by editing the mirror list configuration file:

nano  /etc/pacman.d/mirrorlist

Remove all lines and add the following lines:

## Score: 0.7, United States
Server = http://mirror.us.leaseweb.net/archlinux/$repo/os/$arch
## Score: 0.8, United States
Server = http://lug.mtu.edu/archlinux/$repo/os/$arch
Server = http://mirror.nl.leaseweb.net/archlinux/$repo/os/$arch
## Score: 0.9, United Kingdom
Server = http://mirror.bytemark.co.uk/archlinux/$repo/os/$arch
## Score: 1.5, United Kingdom
Server = http://mirrors.manchester.m247.com/arch-linux/$repo/os/$arch
Server = http://archlinux.dcc.fc.up.pt/$repo/os/$arch
## Score: 6.6, United States
Server = http://mirror.cs.pitt.edu/archlinux/$repo/os/$arch
## Score: 6.7, United States
Server = http://mirrors.acm.wpi.edu/archlinux/$repo/os/$arch
## Score: 6.8, United States
Server = http://ftp.osuosl.org/pub/archlinux/$repo/os/$arch
## Score: 7.1, India
Server = http://mirror.cse.iitk.ac.in/archlinux/$repo/os/$arch
## Score: 10.1, United States
Server = http://mirrors.xmission.com/archlinux/$repo/os/$arch

Save and close the file then update all the package index with the following command:

pacman -Syu

Step 2 – Install Golang

First, visit the Golang official website, pick the latest version of Golang, and download it with the following command.

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

Once the download is completed, extract the downloaded file with the following command.

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

You can verify the content of the extracted file with the following command.

ls /usr/local/go

You should see the following output.

AUTHORS  codereview.cfg  CONTRIBUTORS	  lib  misc	pkg	 SECURITY.md  test

Step 3 – Create Golang Environment Variable

Next, you will need to create or edit the .bashrc file and define your Golang installation path.

nano ~/.bashrc

Add the following line:

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

Save and close the file, then activate the environment variable with the following command.

source ~/.bashrc

You can now verify the Go version with the following command.

go version

You should see the Go version in the following output.

go version go1.18.1 linux/amd64

Step 4 – Create a Project with Golang

First, create a project directory for Golang using the following command.

mkdir project

Next, navigate to the project directory and initialize the project with the following command.

cd project
go mod init go.example.com/hello

Next, create a hello application file with the following command.

nano hello.go

Add the following code.

package main

import "fmt"

func main() {
    fmt.Println("Hello, Go is working")

Save and close the file, then run the Go application using the following command.

go run hello.go

If everything is fine, you should see the following output.

Hello, Go is working


In this post, we showed you how to install Golang on Arch Linux. We also created a sample project with Golang. You can now start developing cloud and web applications using Golang. Deploy the Go application on a dedicated server hosting plan from Atlantic.Net!