Check if Go is installed
Let’s start with checking if Go actually installed on machine.
To see version of Go run this command:
To see Go location run this one:
Default value is
Go installation options
There are multiple ways to setup Go dev environment. Developer can pick an option that provides more flexibility or more simplicity. Flexibility is presented by packaged Go binaries .darwin-amd64.tar.gz archive when simplicity is achieved with package management tools like Homebrew. An option in between is .darwin-amd64.pkg macOS package installer
What is important to understand is that you can have several versions of Go installed on machine using several different methods. In that case, there is no single solution to uninstall all these versions and multiple places need to be checked.
If Go installed using Homebrew
Homebrew is a smart package manager that is capable of cleaning up after itself.
It is recommended to use built-in
uninstall command if Go was installed using
Command below uninstalls Dep and Go if it was installed using
brew uninstall dep brew uninstall go
Homebrew cleans up
$PATH and other config files. No extra steps are necessary if Go was never installed using different options.
brewkeeps Go files in
If Go installed using macOS package
Run the command line to see if Go was installed using macOS package
Go macOS package is presented as
com.googlecode.go in result list.
macOS package stores files in the predefined location. For Go version 1.12 these are the files to be deleted:
There is a command line to check if files are moved to different location in future Go versions:
pkgutil --only-files --files com.googlecode.go
Next step is to remove the system record of Go package:
sudo pkgutil --forget com.googlecode.go
$PATH environment variable to be performed manually as described below.
Removing files manually
/etc/paths.d/gocheck if that file exists and remove. It is added by macOS package.
/usr/local/gocheck if that folder exists and remove. [macOS package] (https://golang.org/dl/) keeps Go files in that folder.
*/go/bin. That is a good hint find where Go is installed. Delete that
$GOPATH- Go Workspace. Important! This folder may contain not pushed code in
/srcsub-folder. Be careful to not lost your work.
$PATHcontains path to Go binaries (
/usr/local/go/binby default). Update
$PATHto exclude path to Go binaries.
$GOPATHmay contain override for workspace path default value
$GOPATHif it exists.