| <!--{ |
| "Title": "Managing Go installations" |
| }--> |
| |
| <p> |
| This topic describes how to install multiple versions of Go on the same machine, as well as how to uninstall Go. |
| </p> |
| |
| <p>For other content on installing, you might be interested in:</p> |
| <ul> |
| <li><a href="/doc/install">Download and install</a> -- The simplest way to get installed and running.</li> |
| <li><a href="/doc/install/source">Installing Go from source</a> -- How to check out the sources, build them on your own machine, and run them.</li> |
| </ul> |
| |
| <h2 id="installing-multiple">Installing multiple Go versions</h2> |
| |
| <p> |
| 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 <a href="/dl/">download page</a>. |
| </p> |
| |
| <p> |
| <strong>Note:</strong> To install using the method described here, you'll need to have <a href="https://git-scm.com/">git</a> installed. |
| </p> |
| |
| <p> |
| To install additional Go versions, run the <a href="/cmd/go/#hdr-Compile_and_install_packages_and_dependencies"><code>go install</code> command</a>, specifying the download location of the version you want to install. The following example illustrates with version 1.10.7: |
| </p> |
| |
| <pre> |
| $ go install golang.org/dl/go1.10.7@latest |
| $ go1.10.7 download |
| </pre> |
| |
| <p> |
| To run <code>go</code> commands with the newly-downloaded version, append the version number to the <code>go</code> command, as follows: |
| </p> |
| |
| <pre> |
| $ go1.10.7 version |
| go version go1.10.7 linux/amd64 |
| </pre> |
| |
| <p> |
| When you have multiple versions installed, you can discover where each is installed, look at the version's <code>GOROOT</code> value. For example, run a command such as the following: |
| </p> |
| |
| <pre> |
| $ go1.10.7 env GOROOT |
| </pre> |
| |
| <p> |
| To uninstall a downloaded version, just remove the directory specified by its <code>GOROOT</code> environment variable and the goX.Y.Z binary. |
| </p> |
| |
| <h2 id="uninstalling">Uninstalling Go</h2> |
| |
| <p> |
| You can remove Go from your system using the steps described in this topic. |
| </p> |
| |
| <h3 id="remove-config">Removing user config and data</h3> |
| |
| <p> |
| Go stores user configuration in the <code>go</code> directory within the user configuration directory, |
| as returned by <a href="/pkg/os#UserConfigDir"><code>os.UserConfigDir</code></a>. |
| This can also be found as the directory containing the config file returned by <code>go env GOENV</code>. |
| </p> |
| |
| <p> |
| Go stores intermediate build artifacts in the directory returned by <code>go env GOCACHE</code>. |
| These can be removed with <code>go clean -cache</code>. |
| </p> |
| |
| <p> |
| Go stores downloaded dependencies in the directory returned by <code>go env GOMODCACHE</code>. |
| These can be removed with <code>go clean -modcache</code>. |
| </p> |
| |
| <p> |
| Go stores binaries installed with <code>go install</code> in the Go bin directory, |
| as returned by <code>go env GOBIN</code> (which defaults to <code>$HOME/go/bin</code>). |
| These can be removed by deleting that directory. If you added this directory to your |
| <code>PATH</code> environment variable, you should also remove it. |
| </p> |
| |
| |
| <div id="os-install-tabs" class="TabSection js-tabSection"> |
| <div id="os-install-tablist" class="TabSection-tabList" role="tablist"> |
| <button |
| role="tab" |
| aria-selected="true" |
| aria-controls="linux-tab" |
| id="linux" |
| tabindex="0" |
| class="TabSection-tab active" |
| > |
| Linux |
| <img class="TabSection-underline" src="/images/icons/underline.svg" width="51" height="4" aria-hidden="true" /> |
| </button> |
| <button |
| role="tab" |
| aria-selected="false" |
| aria-controls="mac-tab" |
| id="mac" |
| tabindex="-1" |
| class="TabSection-tab" |
| > |
| Mac |
| <img class="TabSection-underline" src="/images/icons/underline.svg" width="51" height="4" aria-hidden="true" /> |
| </button> |
| <button |
| role="tab" |
| aria-selected="false" |
| aria-controls="windows-tab" |
| id="windows" |
| tabindex="-1" |
| class="TabSection-tab" |
| > |
| Windows |
| <img class="TabSection-underline" src="/images/icons/underline.svg" width="51" height="4" aria-hidden="true" /> |
| </button> |
| </div> |
| |
| <div |
| role="tabpanel" |
| id="linux-tab" |
| class="TabSection-tabPanel" |
| aria-labelledby="linux" |
| > |
| <ol> |
| <li>Remove <code>/usr/local/go</code>. |
| <p>This is the default installation directory.</p> |
| </li> |
| <li>Remove <code>/usr/local/go</code> from your <code>PATH</code> environment variable. |
| <p>Under Linux and FreeBSD, edit <code>/etc/profile</code> or <code>$HOME/.profile</code>.</p> |
| </li> |
| <li> |
| If you manually added the Go bin directory (typically <code>$HOME/go/bin</code>) to your shell profile, for example by adding <code>export PATH="$PATH:$(go env GOPATH)/bin"</code>, remove that entry. |
| <p><!-- for consistent spacing --></p> |
| </li> |
| <li> |
| Restart any open terminal sessions for the changes to take effect. |
| <p><!-- for consistent spacing --></p> |
| </li> |
| </ol> |
| </div> |
| |
| <div |
| role="tabpanel" |
| id="mac-tab" |
| class="TabSection-tabPanel" |
| aria-labelledby="mac" |
| hidden |
| > |
| <ol> |
| <li>Remove <code>/usr/local/go</code>. |
| <p>This is the default installation directory.</p> |
| </li> |
| <li>Remove <code>/usr/local/go</code> from your <code>PATH</code> environment variable. |
| <p>If you installed Go with the macOS package, do this by removing the <code>/etc/paths.d/go</code> file.</p> |
| </li> |
| <li> |
| If you manually added the Go bin directory (typically <code>$HOME/go/bin</code>) to your shell profile, for example by adding <code>export PATH="$PATH:$(go env GOPATH)/bin"</code>, remove that entry. |
| <p><!-- for consistent spacing --></p> |
| </li> |
| <li> |
| Restart any open terminal sessions for the changes to take effect. |
| <p><!-- for consistent spacing --></p> |
| </li> |
| </ol> |
| </div> |
| |
| <div |
| role="tabpanel" |
| id="windows-tab" |
| class="TabSection-tabPanel" |
| aria-labelledby="windows" |
| hidden |
| > |
| <p>You can remove Go from Windows using one of the following methods:</p> |
| |
| <div class="windows-uninstall-method"> |
| <h4>Method 1: Control Panel (Simplest)</h4> |
| <ol> |
| <li>Open Control Panel and double-click <strong>Add/Remove Programs</strong>.</li> |
| <li>Select <strong>Go Programming Language</strong>, click Uninstall, then follow the prompts.</li> |
| </ol> |
| </div> |
| |
| <div class="windows-uninstall-method"> |
| <h4>Method 2: Command Line</h4> |
| <p>Uninstall using the command line by running the following command:</p> |
| <pre>msiexec /x go{{version}}.windows-{{cpu-arch}}.msi /q</pre> |
| <p> |
| <strong>Note:</strong> Using this process automatically removes Windows environment variables created by the original installation. |
| </p> |
| </div> |
| </div> |
| </div> |
| |
| <style> |
| #windows-tab { |
| padding: 1rem 1.5rem; |
| } |
| .windows-uninstall-method { |
| margin-bottom: 1.5rem; |
| } |
| .windows-uninstall-method h4 { |
| margin-top: 0; |
| margin-bottom: 0.5rem; |
| } |
| </style> |
| |
| <script src="/doc/manage-install.js"></script> |
| |