go

Step-by-step guide to install Go on macOS:

  1. Open a web browser and go to the official Go download page at https://golang.org/dl/.

Once the download is complete, open the package by double-clicking on the file. This will launch the Go installer.

  1. In the Terminal window, type the following command to verify that Go is installed and working properly:
$ go version
go version go1.20.1 darwin/amd64
  1. Next, you will need to set your Go workspace. The workspace is the directory where your Go projects and packages will be stored. To set your workspace, create a new directory in your home directory by running the following command:
mkdir ~/go

After creating the directory, you’ll need to set the GOPATH environment variable to point to your workspace directory. To do this, add the following line to your ~/.zshrc file:

export GOPATH=$HOME/go

You can do this by opening the file in a text editor using the following command:

nano ~/.zshrc

Then add the above line to the end of the file and save it by pressing Ctrl+X, then Y, then Enter.

  1. Finally, restart the Terminal app to apply the changes to the GOPATH environment variable.

Uninstall go

  1. Check in Terminal if go was installed with package
$ pkgutil --pkgs | grep golang
org.golang.go
  1. Check where files are istalled
$ pkgutil --files org.golang.go | more
etc
etc/paths.d
etc/paths.d/go
usr
usr/local
usr/local/go
usr/local/go/CONTRIBUTING.md
usr/local/go/LICENSE
...
  1. Remove folder recursively
$ rm -r /usr/local/go
  1. Remove the system record of the go package.
$ sudo pkgutil --forget org.golang.go.pkg