Managing Go installations
This topic describes how to install multiple versions of Go on the same machine, as well as how to uninstall Go.
For other content on installing, you might be interested in:
- Download and install -- The simplest way to get installed and running.
- Installing Go from source -- How to check out the sources, build them on your own machine, and run them.
Installing multiple Go versions
You can install multiple Go versions on the same machine. For example, you might want to test your code on multiple Go versions. For a list of versions you can install this way, see the download page.
Note: To install using the method described here, you'll need to have git installed.
To install additional Go versions, run the go install command, specifying the download location of the version you want to install. The following example illustrates with version 1.10.7:
$ go install golang.org/dl/go1.10.7@latest $ go1.10.7 download
To run go commands with the newly-downloaded version, append the version number to the go command, as follows:
$ go1.10.7 version go version go1.10.7 linux/amd64
When you have multiple versions installed, you can discover where each is installed, look at the version's GOROOT value. For example, run a command such as the following:
$ go1.10.7 env GOROOT
To uninstall a downloaded version, just remove the directory specified by its GOROOT environment variable and the goX.Y.Z binary.
Uninstalling Go
You can remove Go from your system using the steps described in this topic.
Removing user config and data
Go stores user configuration in the go directory within the user configuration directory,
as returned by os.UserConfigDir.
This can also be found as the directory containing the config file returned by go env GOENV.
Go stores intermediate build artifacts in the directory returned by go env GOCACHE.
These can be removed with go clean -cache.
Go stores downloaded dependencies in the directory returned by go env GOMODCACHE.
These can be removed with go clean -modcache.
Go stores binaries installed with go install in the Go bin directory,
as returned by go env GOBIN (which defaults to $HOME/go/bin).
These can be removed by deleting that directory. If you added this directory to your
PATH environment variable, you should also remove it.
- Remove
/usr/local/go.This is the default installation directory.
- Remove
/usr/local/gofrom yourPATHenvironment variable.Under Linux and FreeBSD, edit
/etc/profileor$HOME/.profile. -
If you manually added the Go bin directory (typically
$HOME/go/bin) to your shell profile, for example by addingexport PATH="$PATH:$(go env GOPATH)/bin", remove that entry. - Restart any open terminal sessions for the changes to take effect.
- Remove
/usr/local/go.This is the default installation directory.
- Remove
/usr/local/gofrom yourPATHenvironment variable.If you installed Go with the macOS package, do this by removing the
/etc/paths.d/gofile. -
If you manually added the Go bin directory (typically
$HOME/go/bin) to your shell profile, for example by addingexport PATH="$PATH:$(go env GOPATH)/bin", remove that entry. - Restart any open terminal sessions for the changes to take effect.
You can remove Go from Windows using one of the following methods:
Method 1: Control Panel (Simplest)
- Open Control Panel and double-click Add/Remove Programs.
- Select Go Programming Language, click Uninstall, then follow the prompts.
Method 2: Command Line
Uninstall using the command line by running the following command:
msiexec /x go{{version}}.windows-{{cpu-arch}}.msi /q
Note: Using this process automatically removes Windows environment variables created by the original installation.