What is Go ?
Go is an open-source programming language developed by a team at Google. It provides easy to build simple, reliable, and efficient software. This language is designed for writing servers, that’s why it is using widely these days. At the update time of this tutorial Go 1.17 is the latest version available. This tutorial will help you to install Go 1.17 on your macOS operating system.
Step 1 – Download Go
To download the latest Go release visit https://golang.org/dl/. You will see the download link for Apple macOS. The current version of Go 1.17 support macOS 10.10 or later versions with 64-bit support only.
Alternatively, you can download Go 1.17.7 using the curl command line.
curl -o golang.pkg https://dl.google.com/go/go1.17.7.darwin-amd64.pkg
Step 2 – Install Go on macOS
You have downloaded the Go package on your macOS system. To install it simply double click on the downloaded file to start the installation wizard.
Command-line users can execute the below command to start the installation.
sudo open golang.pkg
Follow the installation wizard and complete the installation process.
Step 3 – Setup Go Workspace
~/.profile file (or its equivalent) to set environment variables. Commonly you need to set 3 environment variables as GOROOT, GOPATH and PATH.
GOROOT is the location where Go package is installed on your system.
GOPATH is the location of your work directory. For example my project directory is ~/Projects/Proj1 .
Now set the PATH variable to access go binary system wide.
Step 4 – Install Dependency Management Tool
The govendor is a tool used for managing the Go application dependencies efficiently. You should consider this to install on your system.
go get -u github.com/kardianos/govendor
Step 5 – Test Go Version
Finally, you have successfully installed and configured go language on your system. First, use the following command to check the installed Go version.
go versiongo version go1.17.7 darwin/amd64
In this tutorial, you have learned to install Golang on macOS operating system.