Getting started with Go in macOS

Golang is a programming language introduced by Google in 2009. The reason behind its development is due to frustration at Google, since developers continually had to pick a language that executed efficiently but took a long time to compile, other languages that ran inefficiently in production, but easy to program. Hence, Golang was designed for fast compilation, ease of programming and efficient execution in production.

Go can be used for many different programming projects since it is a versatile programming language. It is well suited for networking/distributed systems programs and widely used in the cloud environment since developers can do more with a strong set of tools and deployment becomes easy since only a single binary must be compiled. Furthermore, Go is easy to learn due to its small set of keywords, which also make a good choice for beginners and experienced developers.


Installing Go is a very straightforward process. In this article, we are going to show you how to install Go on macOS. There is some package management software available in macOS which makes the Golang installation easier. In this article, we are going to demonstrate how to install Go using the standard macOS package installer and using the open-source package management software Homebrew.

Installing Golang using the standard macOS package installer

The Golang package installer can be downloaded through this link: After downloading the package installer, open it and follow the prompts to install the Go tools. By default, the package installs the Go distribution to the usr/local/go directory.

Go directory

After installing Go using the package installer, following these steps to navigate to the go directory in order to verify if it is successfully added.

1. Go to finder -> Go to folder

2. Insert the following directory path: /usr/local and click on Go.

3. If Golang is successfully installed on your Mac, you must be able to see the Go directory in this location.

Go bin directory

In this directory, the package should place the /usr/local/go/bin directory in your PATH environment variable. The PATH environment we will further discuss later in this article.

The following steps show how to verify if the bin folder is added to the Go directory. See illustration below:

For more information, visit:

Installing Golang using Homebrew

Homebrew is a package management system that simplifies the installation of software on macOS and Linux. To install HomeBrew on your mac just copy and paste the following in your terminal:

/usr/bin/ruby -e "$(curl -fsSL

For more information on Homebrew, visit (

After brew is successfully installed, you can verify it by using the following command:

brew help

If Homebrew is successfully installed you will get the following result:

Installing HomeBrew is not a straight forward process so there are a few steps that need to be taken before proceeding.

Configure your .bash_profile

1. Open terminal and type the following command to open your .bash_profile:

nano .bash_profile

2. Ones the .bash_profile open in terminal add the following lines:

  • Export GOPATH=”${HOME}/go” (default go path)
  • Export GOROOT=”$(brew –prefix golang)/libexec” (were the Golang executable will be stored)
  • Export PATH=”$PATH:${GOPATH}/bin:${GOROOT}/bin” (this is important when you launch your terminal, the environment variable will be set)

After setting these variables open press Ctrl + X and it will ask you if you want save the changes. Type Y and press return, it will go back to the home directory.

Install Go using HomeBrew

On completing the previous steps, just enter the following command in terminal: brew install go and the installation will begin and it will take a while to complete.

Check if Go is installed on your machine

In order to check if Go is successfully installed on your mac you can execute the following two commands in terminal:

  • go

This command gives the following result:

  • go version

This command gives the following result:

Relevant resources:

Follow us:

One reply on “Getting started with Go in macOS”

Leave a Reply

Your email address will not be published. Required fields are marked *