How to Install Golang on a Mac

Hey! If you love Go and building Go apps as much as I do, let's connect on Twitter or LinkedIn. I talk about this stuff all the time!

Want to learn how to build better Go applications faster and easier? You can.

Check out my course on the Go Standard Library. You can check it out now for free.


If you want to install Go on a Mac, it’s easy.

  1. Download the latest stable release of Go from the official website.

  2. Extract the downloaded tarball using the following command:

tar -xvf go1.x.x.darwin-amd64.tar.gz

Replace x.x with the actual version number of Go.

  1. Move the extracted directory to the desired location. It is recommended to place it in /usr/local, as this will allow all everyone to use Go.
sudo mv go /usr/local
  1. Add the Go bin directory to your PATH environment variable. Open your ~/.bash_profile file and add this line at the end:
export PATH=$PATH:/usr/local/go/bin
  1. Reload the ~/.bash_profile file to apply the changes:
source ~/.bash_profile
  1. Verify the installation by checking the Go version:
go version

This should print the installed version of Go.

You may also want to set up your Go workspace by defining the GOPATH environment variable. The GOPATH variable specifies the location of your Go workspace, where your Go source code and libraries are stored. By default, the go command will look for packages in the $GOPATH/src directory and will store the compiled binaries in the $GOPATH/bin directory.

To set the GOPATH variable, open the ~/.bash_profile file and add the following line:

export GOPATH=$HOME/go

Replace $HOME/go with the desired location of your Go workspace.

Don’t forget to reload your ~/.bash_profile file to apply the changes:

source ~/.bash_profile

That’s it! You now have Go installed on your Mac.



Stay up to date on the latest in Coding for AI and Data Science

Intuit Mailchimp