blob: 855157ba3126d4986a48444d5afee1efef8c5072 [file] [log] [blame]
<!--{
"Title": "Download and install",
"HideTOC": true,
"Sidebar": "bug"
}-->
<p>
Download and install Go quickly with the steps described here.
</p>
<p>For other content on installing, you might be interested in:</p>
<ul>
<li>
<a href="/doc/manage-install">Managing Go installations</a> -- How to
install multiple versions and uninstall.
</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>
<p class="DownloadBtn">
<a href="/dl/" id="start" class="btn download js-download">
<span id="download-description" class="js-downloadDescription"></span>
</a>
</p>
<p>
Don't see your operating system here? Try one of the
<a href="/dl/">other downloads</a>.
</p>
<h2 id="install">Go installation</h2>
<p>
Select the tab for your computer's operating system below, then follow its
installation instructions.
</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>
<strong>Remove any previous Go installation</strong> by deleting the /usr/local/go folder
(if it exists), then extract the archive you just downloaded into /usr/local, creating a fresh
Go tree in /usr/local/go:
<pre class="CopyPaste">
<span>$ rm -rf /usr/local/go && tar -C /usr/local -xzf <span id="linux-filename">go1.14.3.linux-amd64.tar.gz</span></span>
<button aria-label="Copy and paste the code.">
<img class="CopyPaste-icon" src="/images/icons/copy-paste.svg" />
<img class="CopyPaste-icon CopyPaste-icon-dark" src="/images/icons/copy-paste-dark.svg" />
</button>
</pre>
<p>
(You may need to run the command as root or through <code>sudo</code>).
</p>
<p>
<strong>Do not</strong> untar the archive into an existing /usr/local/go tree. This is known to
produce broken Go installations.
</p>
</li>
<li>
Add /usr/local/go/bin to the <code>PATH</code> environment variable.
<p>
You can do this by adding the following line to your $HOME/.profile or
/etc/profile (for a system-wide installation):
</p>
<pre class="CopyPaste">
<span>export PATH=$PATH:/usr/local/go/bin</span>
<button aria-label="Copy and paste the code.">
<img class="CopyPaste-icon" src="/images/icons/copy-paste.svg" />
<img class="CopyPaste-icon CopyPaste-icon-dark" src="/images/icons/copy-paste-dark.svg" />
</button>
</pre>
<p>
<strong>Note:</strong> Changes made to a profile file may not apply
until the next time you log into your computer. To apply the changes
immediately, just run the shell commands directly or execute them from
the profile using a command such as
<code>source $HOME/.profile</code>.
</p>
</li>
<li>
Verify that you've installed Go by opening a command prompt and typing
the following command:
<pre class="CopyPaste">
<span>$ go version</span>
<button aria-label="Copy and paste the code.">
<img class="CopyPaste-icon" src="/images/icons/copy-paste.svg" />
<img class="CopyPaste-icon CopyPaste-icon-dark" src="/images/icons/copy-paste-dark.svg" />
</button>
</pre>
</li>
<li>Confirm that the command prints the installed version of Go.</li>
</ol>
</div>
<div
role="tabpanel"
id="mac-tab"
class="TabSection-tabPanel"
aria-labelledby="mac"
hidden
>
<ol>
<li>
Open the package file you downloaded and follow the prompts to install
Go.
<p>
The package installs the Go distribution to /usr/local/go. The package
should put the /usr/local/go/bin directory in your
<code>PATH</code> environment variable. You may need to restart any
open Terminal sessions for the change to take effect.
</p>
</li>
<li>
Verify that you've installed Go by opening a command prompt and typing
the following command:
<pre class="CopyPaste">
<span>$ go version</span>
<button aria-label="Copy and paste the code.">
<img class="CopyPaste-icon" src="/images/icons/copy-paste.svg" />
<img class="CopyPaste-icon CopyPaste-icon-dark" src="/images/icons/copy-paste-dark.svg" />
</button>
</pre>
</li>
<li>Confirm that the command prints the installed version of Go.</li>
</ol>
</div>
<div
role="tabpanel"
id="windows-tab"
class="TabSection-tabPanel"
aria-labelledby="windows"
hidden
>
<ol>
<li>
Open the MSI file you downloaded and follow the prompts to install Go.
<p>
By default, the installer will install Go to <code>Program Files</code>
or <code>Program Files (x86)</code>. You can change the
location as needed. After installing, you will need to close and
reopen any open command prompts so that changes to the environment
made by the installer are reflected at the command prompt.
</p>
</li>
<li>
Verify that you've installed Go.
<ol>
<li>
In <strong>Windows</strong>, click the <strong>Start</strong> menu.
</li>
<li>
In the menu's search box, type <code>cmd</code>, then press the
<strong>Enter</strong> key.
</li>
<li>
In the Command Prompt window that appears, type the following
command:
<pre class="CopyPaste">
<span>$ go version</span>
<button aria-label="Copy and paste the code.">
<img class="CopyPaste-icon" src="/images/icons/copy-paste.svg" />
<img class="CopyPaste-icon CopyPaste-icon-dark" src="/images/icons/copy-paste-dark.svg" />
</button>
</pre>
</li>
<li>Confirm that the command prints the installed version of Go.</li>
</ol>
</li>
</ol>
</div>
</div>
<h2 id="code">You're all set!</h2>
<p class="DocInstall-footer">
Visit the
<a href="tutorial/getting-started.html">Getting Started tutorial</a> to write
some simple Go code. It takes about 10 minutes to complete.
</p>
<script async src="/doc/download.js"></script>
<script async src="/doc/hats.js"></script>
<script async src="/js/copypaste.js"></script>