Home Alpine Linux How to Install Go Programming Language in Alpine Linux

How to Install Go Programming Language in Alpine Linux

Golang, also shortened as Go, is a free and open-source statically typed programming language that focuses on simplicity, efficiency, and reliability. It was originally developed for applications related to infrastructure and networking and was intended to replace server-side apps such as C and Java.

Over time, Go has become hugely popular. It is used to write command-line tools and is widely used in artificial intelligence, cloud-based, and server-side applications. However, Go really performs the best when it comes to infrastructure. Some of the popular DevOps tools such as Kubernetes and Docker.

In this short guide, we will explore how you can install Go in Alpine Linux.


Before you get started, ensure that you have an instance of Alpine Linux installed with SSH access.

Installing Go in Alpine Linux

To get off the ground, log in to your Alpine instance and add community repositories as shown.

cat > /etc/apk/repositories << EOF; $(echo)

https://dl-cdn.alpinelinux.org/alpine/v$(cat /etc/alpine-release | cut -d'.' -f1,2)/main/
https://dl-cdn.alpinelinux.org/alpine/v$(cat /etc/alpine-release | cut -d'.' -f1,2)/community/

Add Alpine Community Repositories
Add Alpine Community Repositories

Next, install Go and other essential packages as follows.

# apk add --update --no-cache go vim git make musl-dev curl
Install Go in Alpine Linux
Install Go in Alpine Linux

Once that is done, export the following variables as follows.

export GOPATH=/root/go
export PATH=${GOPATH}/bin:/usr/local/go/bin:$PATH
export GOBIN=$GOROOT/bin
mkdir -p ${GOPATH}/src ${GOPATH}/bin
export GO111MODULE=on
Export Variables
Export Variables

With that out of the way, verify that Go is successfully installed:

$ go version
Check Go Version
Check Go Version

Creating a Simple Go Program

To test our Go installation, we will create a simple Go program using the vim editor as shown.

$ vim hello.go

We will then write the following lines of code. The code simply prints a simple message to stdout. Feel free to paste the code into your editor.

package main
import "fmt"
func main() {
    fmt.Printf("Hello guys, welcome to Go Programming\n")

Save the changes and exit.

Then run the Go application as follows.

$ go run hello.go
Run Go Program
Run Go Program

This is a confirmation that Go has successfully been installed. And there you go. We have successfully installed Go on Alpine Linux.

Ravi Saive
I am an Experienced GNU/Linux expert and a full-stack software developer with over a decade in the field of Linux and Open Source technologies. Founder of TecMint.com, LinuxShellTips.com, and Fossmint.com. Over 150+ million people visited my websites.

Each tutorial at UbuntuMint is created by a team of experienced writers so that it meets our high-quality standards.

Was this article helpful? Please add a comment to show your appreciation and support.

Got something to say? Join the discussion.

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published or shared. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.