Go is a compiled programming language developed by Google in 2009. It has gained popularity in the software development industry due to its performance, readability, and simplicity. Go is a general-purpose programming language that feels natural with code snippets that can be written in fewer lines of code than other languages like C or Java. Golang programming has become one of the most popular choices for software developers across the world.
If you are also looking to get started with Golang on your Mac OS computer, this blog will help you get through it easily by providing you with all the necessary details about how to install Golang on macOS and all the other information you need to get started with Golang on your Mac computer.
Step 1 – Download Golang
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.19 support macOS 10.10 or later versions with 64-bit support only.
Alternatively, you can download Go 1.19 using the curl command line tool.
curl -o golang.pkg https://dl.google.com/go/go1.19.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-mentioned command to begin the installation.
sudo open golang.pkg
An installation wizard will start. Follow the on-screen instruction 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.
- Set the GOROOT, which is the location of the Golang installation directory.
- Then set the GOPATH environment variable, which is the location of your work directory. For example my project directory is ~/Projects/Proj1 .
- Now update the PATH environment variable to access go binary system wide.
Step 4 – Install Go Dependency Management Tool
The govendor is a tool used for managing the Go application dependencies efficiently. You should consider this for installation on your system.
go get -u github.com/kardianos/govendor
Now, you can easily install and manage go packages for your application.
Step 5 – Check 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.19 darwin/amd64
In this tutorial, you have learned to install Golang on macOS operating system. Now, you can use any text editor to start development with the Go programming language. You may also like to install Visual Studio Code on your macOS.