| <!--{ | |
| "Title": "Download and install", | |
| "HideTOC": true, | |
| "Sidebar": "bug", | |
| "Breadcrumb": true | |
| }--> | |
| <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"> | |
| <span id="download-description" class="js-downloadDescription"> | |
| Download | |
| </span> | |
| </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 <code>/usr/local/go</code> folder | |
| (if it exists), then extract the archive you just downloaded into <code>/usr/local</code>, creating a fresh | |
| Go tree in <code>/usr/local/go</code>: | |
| <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 each command separately with the necessary permissions, as root or through <code>sudo</code>.) | |
| </p> | |
| <p> | |
| <strong>Do not</strong> untar the archive into an existing <code>/usr/local/go</code> tree. This is known to | |
| produce broken Go installations. | |
| </p> | |
| </li> | |
| <li> | |
| Add <code>/usr/local/go/bin</code> to the <code>PATH</code> environment variable. | |
| <p> | |
| You can do this by adding the following line to your <code>$HOME/.profile</code> or | |
| <code>/etc/profile</code> (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> | |
| <!-- TODO: Update to GOBIN once go.dev/issue/23439 is addressed. --> | |
| Add <code>$HOME/go/bin</code> (the default Go bin path) to your | |
| <code>PATH</code> environment variable to use tools installed via | |
| <code>go install</code>. | |
| <p> | |
| You can do this by adding the following line to your <code>$HOME/.profile</code> or <code>$HOME/.bashrc</code> file: | |
| </p> | |
| <pre class="CopyPaste"> | |
| <span>export PATH="$PATH:$(go env GOPATH)/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> | |
| </li> | |
| <li> | |
| Restart any open terminal sessions for the changes to take effect. | |
| <p><!-- for consistent spacing --></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 <code>/usr/local/go</code>. The package | |
| adds the <code>/usr/local/go/bin</code> directory to your | |
| <code>PATH</code> environment variable by creating a <code>/etc/paths.d/go</code> file. | |
| </p> | |
| </li> | |
| <li> | |
| <!-- TODO: Update to GOBIN once go.dev/issue/23439 is addressed. --> | |
| Add <code>$HOME/go/bin</code> (the default Go bin path) to your | |
| <code>PATH</code> environment variable to use tools installed via | |
| <code>go install</code>. | |
| <p> | |
| You can do this by adding the following line to your <code>~/.zshrc</code> or <code>~/.bash_profile</code> file: | |
| </p> | |
| <pre class="CopyPaste"> | |
| <span>export PATH="$PATH:$(go env GOPATH)/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> | |
| </li> | |
| <li> | |
| Restart any open terminal sessions for the changes to take effect. | |
| <p><!-- for consistent spacing --></p> | |
| </li> | |
| <li> | |
| Verify that you've installed Go by opening a <strong>new</strong> terminal session 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> |