doc: remove install.html and install-source.html

These live in x/website/content/doc now.
The copies here just attract edits that have no actual effect.

For #40496.
For #41861.

Change-Id: I2fdd7375e373949eb9a88f4cdca440b6a5d45eea
Reviewed-on: https://go-review.googlesource.com/c/go/+/291709
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
This commit is contained in:
Russ Cox 2021-02-12 16:02:12 -05:00
parent 30641e36aa
commit 626ef08127
3 changed files with 4 additions and 1098 deletions

View file

@ -19,22 +19,20 @@ BSD-style license found in the LICENSE file.
Official binary distributions are available at https://golang.org/dl/.
After downloading a binary release, visit https://golang.org/doc/install
or load [doc/install.html](./doc/install.html) in your web browser for installation
instructions.
for installation instructions.
#### Install From Source
If a binary distribution is not available for your combination of
operating system and architecture, visit
https://golang.org/doc/install/source or load [doc/install-source.html](./doc/install-source.html)
in your web browser for source installation instructions.
https://golang.org/doc/install/source
for source installation instructions.
### Contributing
Go is the work of thousands of contributors. We appreciate your help!
To contribute, please read the contribution guidelines:
https://golang.org/doc/contribute.html
To contribute, please read the contribution guidelines at https://golang.org/doc/contribute.html.
Note that the Go project uses the issue tracker for bug reports and
proposals only. See https://golang.org/wiki/Questions for a list of

View file

@ -1,777 +0,0 @@
<!--{
"Title": "Installing Go from source",
"Path": "/doc/install/source"
}-->
<h2 id="introduction">Introduction</h2>
<p>
Go is an open source project, distributed under a
<a href="/LICENSE">BSD-style license</a>.
This document explains how to check out the sources,
build them on your own machine, and run them.
</p>
<p>
Most users don't need to do this, and will instead install
from precompiled binary packages as described in
<a href="/doc/install">Getting Started</a>,
a much simpler process.
If you want to help develop what goes into those precompiled
packages, though, read on.
</p>
<div class="detail">
<p>
There are two official Go compiler toolchains.
This document focuses on the <code>gc</code> Go
compiler and tools.
For information on how to work on <code>gccgo</code>, a more traditional
compiler using the GCC back end, see
<a href="/doc/install/gccgo">Setting up and using gccgo</a>.
</p>
<p>
The Go compilers support the following instruction sets:
<dl>
<dt>
<code>amd64</code>, <code>386</code>
</dt>
<dd>
The <code>x86</code> instruction set, 64- and 32-bit.
</dd>
<dt>
<code>arm64</code>, <code>arm</code>
</dt>
<dd>
The <code>ARM</code> instruction set, 64-bit (<code>AArch64</code>) and 32-bit.
</dd>
<dt>
<code>mips64</code>, <code>mips64le</code>, <code>mips</code>, <code>mipsle</code>
</dt>
<dd>
The <code>MIPS</code> instruction set, big- and little-endian, 64- and 32-bit.
</dd>
<dt>
<code>ppc64</code>, <code>ppc64le</code>
</dt>
<dd>
The 64-bit PowerPC instruction set, big- and little-endian.
</dd>
<dt>
<code>riscv64</code>
</dt>
<dd>
The 64-bit RISC-V instruction set.
</dd>
<dt>
<code>s390x</code>
</dt>
<dd>
The IBM z/Architecture.
</dd>
<dt>
<code>wasm</code>
</dt>
<dd>
<a href="https://webassembly.org">WebAssembly</a>.
</dd>
</dl>
</p>
<p>
The compilers can target the AIX, Android, DragonFly BSD, FreeBSD,
Illumos, Linux, macOS/iOS (Darwin), NetBSD, OpenBSD, Plan 9, Solaris,
and Windows operating systems (although not all operating systems
support all architectures).
</p>
<p>
A list of ports which are considered "first class" is available at the
<a href="/wiki/PortingPolicy#first-class-ports">first class ports</a>
wiki page.
</p>
<p>
The full set of supported combinations is listed in the
discussion of <a href="#environment">environment variables</a> below.
</p>
<p>
See the main installation page for the <a href="/doc/install#requirements">overall system requirements</a>.
The following additional constraints apply to systems that can be built only from source:
</p>
<ul>
<li>For Linux on PowerPC 64-bit, the minimum supported kernel version is 2.6.37, meaning that
Go does not support CentOS 6 on these systems.
</li>
</ul>
</div>
<h2 id="go14">Install Go compiler binaries for bootstrap</h2>
<p>
The Go toolchain is written in Go. To build it, you need a Go compiler installed.
The scripts that do the initial build of the tools look for a "go" command
in <code>$PATH</code>, so as long as you have Go installed in your
system and configured in your <code>$PATH</code>, you are ready to build Go
from source.
Or if you prefer you can set <code>$GOROOT_BOOTSTRAP</code> to the
root of a Go installation to use to build the new Go toolchain;
<code>$GOROOT_BOOTSTRAP/bin/go</code> should be the go command to use.</p>
<p>
There are four possible ways to obtain a bootstrap toolchain:
</p>
<ul>
<li>Download a recent binary release of Go.
<li>Cross-compile a toolchain using a system with a working Go installation.
<li>Use gccgo.
<li>Compile a toolchain from Go 1.4, the last Go release with a compiler written in C.
</ul>
<p>
These approaches are detailed below.
</p>
<h3 id="bootstrapFromBinaryRelease">Bootstrap toolchain from binary release</h3>
<p>
To use a binary release as a bootstrap toolchain, see
<a href="/dl/">the downloads page</a> or use any other
packaged Go distribution.
</p>
<h3 id="bootstrapFromCrosscompiledSource">Bootstrap toolchain from cross-compiled source</h3>
<p>
To cross-compile a bootstrap toolchain from source, which is
necessary on systems Go 1.4 did not target (for
example, <code>linux/ppc64le</code>), install Go on a different system
and run <a href="/src/bootstrap.bash">bootstrap.bash</a>.
</p>
<p>
When run as (for example)
</p>
<pre>
$ GOOS=linux GOARCH=ppc64 ./bootstrap.bash
</pre>
<p>
<code>bootstrap.bash</code> cross-compiles a toolchain for that <code>GOOS/GOARCH</code>
combination, leaving the resulting tree in <code>../../go-${GOOS}-${GOARCH}-bootstrap</code>.
That tree can be copied to a machine of the given target type
and used as <code>GOROOT_BOOTSTRAP</code> to bootstrap a local build.
</p>
<h3 id="bootstrapFromGccgo">Bootstrap toolchain using gccgo</h3>
<p>
To use gccgo as the bootstrap toolchain, you need to arrange
for <code>$GOROOT_BOOTSTRAP/bin/go</code> to be the go tool that comes
as part of gccgo 5. For example on Ubuntu Vivid:
</p>
<pre>
$ sudo apt-get install gccgo-5
$ sudo update-alternatives --set go /usr/bin/go-5
$ GOROOT_BOOTSTRAP=/usr ./make.bash
</pre>
<h3 id="bootstrapFromSource">Bootstrap toolchain from C source code</h3>
<p>
To build a bootstrap toolchain from C source code, use
either the git branch <code>release-branch.go1.4</code> or
<a href="https://dl.google.com/go/go1.4-bootstrap-20171003.tar.gz">go1.4-bootstrap-20171003.tar.gz</a>,
which contains the Go 1.4 source code plus accumulated fixes
to keep the tools running on newer operating systems.
(Go 1.4 was the last distribution in which the toolchain was written in C.)
After unpacking the Go 1.4 source, <code>cd</code> to
the <code>src</code> subdirectory, set <code>CGO_ENABLED=0</code> in
the environment, and run <code>make.bash</code> (or,
on Windows, <code>make.bat</code>).
</p>
<p>
Once the Go 1.4 source has been unpacked into your GOROOT_BOOTSTRAP directory,
you must keep this git clone instance checked out to branch
<code>release-branch.go1.4</code>. Specifically, do not attempt to reuse
this git clone in the later step named "Fetch the repository." The go1.4
bootstrap toolchain <b>must be able</b> to properly traverse the go1.4 sources
that it assumes are present under this repository root.
</p>
<p>
Note that Go 1.4 does not run on all systems that later versions of Go do.
In particular, Go 1.4 does not support current versions of macOS.
On such systems, the bootstrap toolchain must be obtained using one of the other methods.
</p>
<h2 id="git">Install Git, if needed</h2>
<p>
To perform the next step you must have Git installed. (Check that you
have a <code>git</code> command before proceeding.)
</p>
<p>
If you do not have a working Git installation,
follow the instructions on the
<a href="https://git-scm.com/downloads">Git downloads</a> page.
</p>
<h2 id="ccompiler">(Optional) Install a C compiler</h2>
<p>
To build a Go installation
with <code><a href="/cmd/cgo">cgo</a></code> support, which permits Go
programs to import C libraries, a C compiler such as <code>gcc</code>
or <code>clang</code> must be installed first. Do this using whatever
installation method is standard on the system.
</p>
<p>
To build without <code>cgo</code>, set the environment variable
<code>CGO_ENABLED=0</code> before running <code>all.bash</code> or
<code>make.bash</code>.
</p>
<h2 id="fetch">Fetch the repository</h2>
<p>Change to the directory where you intend to install Go, and make sure
the <code>goroot</code> directory does not exist. Then clone the repository
and check out the latest release tag (<code class="versionTag">go1.12</code>,
for example):</p>
<pre>
$ git clone https://go.googlesource.com/go goroot
$ cd goroot
$ git checkout <span class="versionTag"><i>&lt;tag&gt;</i></span>
</pre>
<p class="whereTag">
Where <code>&lt;tag&gt;</code> is the version string of the release.
</p>
<p>Go will be installed in the directory where it is checked out. For example,
if Go is checked out in <code>$HOME/goroot</code>, executables will be installed
in <code>$HOME/goroot/bin</code>. The directory may have any name, but note
that if Go is checked out in <code>$HOME/go</code>, it will conflict with
the default location of <code>$GOPATH</code>.
See <a href="#gopath"><code>GOPATH</code></a> below.</p>
<p>
Reminder: If you opted to also compile the bootstrap binaries from source (in an
earlier section), you still need to <code>git clone</code> again at this point
(to checkout the latest <code>&lt;tag&gt;</code>), because you must keep your
go1.4 repository distinct.
</p>
<h2 id="head">(Optional) Switch to the master branch</h2>
<p>If you intend to modify the go source code, and
<a href="/doc/contribute.html">contribute your changes</a>
to the project, then move your repository
off the release branch, and onto the master (development) branch.
Otherwise, skip this step.</p>
<pre>
$ git checkout master
</pre>
<h2 id="install">Install Go</h2>
<p>
To build the Go distribution, run
</p>
<pre>
$ cd src
$ ./all.bash
</pre>
<p>
(To build under Windows use <code>all.bat</code>.)
</p>
<p>
If all goes well, it will finish by printing output like:
</p>
<pre>
ALL TESTS PASSED
---
Installed Go for linux/amd64 in /home/you/go.
Installed commands in /home/you/go/bin.
*** You need to add /home/you/go/bin to your $PATH. ***
</pre>
<p>
where the details on the last few lines reflect the operating system,
architecture, and root directory used during the install.
</p>
<div class="detail">
<p>
For more information about ways to control the build, see the discussion of
<a href="#environment">environment variables</a> below.
<code>all.bash</code> (or <code>all.bat</code>) runs important tests for Go,
which can take more time than simply building Go. If you do not want to run
the test suite use <code>make.bash</code> (or <code>make.bat</code>)
instead.
</p>
</div>
<h2 id="testing">Testing your installation</h2>
<p>
Check that Go is installed correctly by building a simple program.
</p>
<p>
Create a file named <code>hello.go</code> and put the following program in it:
</p>
<pre>
package main
import "fmt"
func main() {
fmt.Printf("hello, world\n")
}
</pre>
<p>
Then run it with the <code>go</code> tool:
</p>
<pre>
$ go run hello.go
hello, world
</pre>
<p>
If you see the "hello, world" message then Go is installed correctly.
</p>
<h2 id="gopath">Set up your work environment</h2>
<p>
You're almost done.
You just need to do a little more setup.
</p>
<p>
<a href="/doc/code.html" class="download" id="start">
<span class="big">How to Write Go Code</span>
<span class="desc">Learn how to set up and use the Go tools</span>
</a>
</p>
<p>
The <a href="/doc/code.html">How to Write Go Code</a> document
provides <b>essential setup instructions</b> for using the Go tools.
</p>
<h2 id="tools">Install additional tools</h2>
<p>
The source code for several Go tools (including <a href="/cmd/godoc/">godoc</a>)
is kept in <a href="https://golang.org/x/tools">the go.tools repository</a>.
To install one of the tools (<code>godoc</code> in this case):
</p>
<pre>
$ go get golang.org/x/tools/cmd/godoc
</pre>
<p>
To install these tools, the <code>go</code> <code>get</code> command requires
that <a href="#git">Git</a> be installed locally.
</p>
<p>
You must also have a workspace (<code>GOPATH</code>) set up;
see <a href="/doc/code.html">How to Write Go Code</a> for the details.
</p>
<h2 id="community">Community resources</h2>
<p>
The usual community resources such as
<code>#go-nuts</code> on the <a href="https://freenode.net/">Freenode</a> IRC server
and the
<a href="//groups.google.com/group/golang-nuts">Go Nuts</a>
mailing list have active developers that can help you with problems
with your installation or your development work.
For those who wish to keep up to date,
there is another mailing list, <a href="//groups.google.com/group/golang-checkins">golang-checkins</a>,
that receives a message summarizing each checkin to the Go repository.
</p>
<p>
Bugs can be reported using the <a href="//golang.org/issue/new">Go issue tracker</a>.
</p>
<h2 id="releases">Keeping up with releases</h2>
<p>
New releases are announced on the
<a href="//groups.google.com/group/golang-announce">golang-announce</a>
mailing list.
Each announcement mentions the latest release tag, for instance,
<code class="versionTag">go1.9</code>.
</p>
<p>
To update an existing tree to the latest release, you can run:
</p>
<pre>
$ cd go/src
$ git fetch
$ git checkout <span class="versionTag"><i>&lt;tag&gt;</i></psan>
$ ./all.bash
</pre>
<p class="whereTag">
Where <code>&lt;tag&gt;</code> is the version string of the release.
</p>
<h2 id="environment">Optional environment variables</h2>
<p>
The Go compilation environment can be customized by environment variables.
<i>None is required by the build</i>, but you may wish to set some
to override the defaults.
</p>
<ul>
<li><code>$GOROOT</code>
<p>
The root of the Go tree, often <code>$HOME/go1.X</code>.
Its value is built into the tree when it is compiled, and
defaults to the parent of the directory where <code>all.bash</code> was run.
There is no need to set this unless you want to switch between multiple
local copies of the repository.
</p>
</li>
<li><code>$GOROOT_FINAL</code>
<p>
The value assumed by installed binaries and scripts when
<code>$GOROOT</code> is not set explicitly.
It defaults to the value of <code>$GOROOT</code>.
If you want to build the Go tree in one location
but move it elsewhere after the build, set
<code>$GOROOT_FINAL</code> to the eventual location.
</p>
</li>
<li id="gopath"><code>$GOPATH</code>
<p>
The directory where Go projects outside the Go distribution are typically
checked out. For example, <code>golang.org/x/tools</code> might be checked out
to <code>$GOPATH/src/golang.org/x/tools</code>. Executables outside the
Go distribution are installed in <code>$GOPATH/bin</code> (or
<code>$GOBIN</code>, if set). Modules are downloaded and cached in
<code>$GOPATH/pkg/mod</code>.
</p>
<p>The default location of <code>$GOPATH</code> is <code>$HOME/go</code>,
and it's not usually necessary to set <code>GOPATH</code> explicitly. However,
if you have checked out the Go distribution to <code>$HOME/go</code>,
you must set <code>GOPATH</code> to another location to avoid conflicts.
</p>
</li>
<li><code>$GOBIN</code>
<p>
The directory where executables outside the Go distribution are installed
using the <a href="/cmd/go">go command</a>. For example,
<code>go get golang.org/x/tools/cmd/godoc</code> downloads, builds, and
installs <code>$GOBIN/godoc</code>. By default, <code>$GOBIN</code> is
<code>$GOPATH/bin</code> (or <code>$HOME/go/bin</code> if <code>GOPATH</code>
is not set). After installing, you will want to add this directory to
your <code>$PATH</code> so you can use installed tools.
</p>
<p>
Note that the Go distribution's executables are installed in
<code>$GOROOT/bin</code> (for executables invoked by people) or
<code>$GOTOOLDIR</code> (for executables invoked by the go command;
defaults to <code>$GOROOT/pkg/$GOOS_GOARCH</code>) instead of
<code>$GOBIN</code>.
</p>
</li>
<li><code>$GOOS</code> and <code>$GOARCH</code>
<p>
The name of the target operating system and compilation architecture.
These default to the values of <code>$GOHOSTOS</code> and
<code>$GOHOSTARCH</code> respectively (described below).
</li>
<p>
Choices for <code>$GOOS</code> are
<code>android</code>, <code>darwin</code>, <code>dragonfly</code>,
<code>freebsd</code>, <code>illumos</code>, <code>ios</code>, <code>js</code>,
<code>linux</code>, <code>netbsd</code>, <code>openbsd</code>,
<code>plan9</code>, <code>solaris</code> and <code>windows</code>.
</p>
<p>
Choices for <code>$GOARCH</code> are
<code>amd64</code> (64-bit x86, the most mature port),
<code>386</code> (32-bit x86), <code>arm</code> (32-bit ARM), <code>arm64</code> (64-bit ARM),
<code>ppc64le</code> (PowerPC 64-bit, little-endian), <code>ppc64</code> (PowerPC 64-bit, big-endian),
<code>mips64le</code> (MIPS 64-bit, little-endian), <code>mips64</code> (MIPS 64-bit, big-endian),
<code>mipsle</code> (MIPS 32-bit, little-endian), <code>mips</code> (MIPS 32-bit, big-endian),
<code>s390x</code> (IBM System z 64-bit, big-endian), and
<code>wasm</code> (WebAssembly 32-bit).
</p>
<p>
The valid combinations of <code>$GOOS</code> and <code>$GOARCH</code> are:
<table cellpadding="0">
<tr>
<th width="50"></th><th align="left" width="100"><code>$GOOS</code></th> <th align="left" width="100"><code>$GOARCH</code></th>
</tr>
<tr>
<td></td><td><code>aix</code></td> <td><code>ppc64</code></td>
</tr>
<tr>
<td></td><td><code>android</code></td> <td><code>386</code></td>
</tr>
<tr>
<td></td><td><code>android</code></td> <td><code>amd64</code></td>
</tr>
<tr>
<td></td><td><code>android</code></td> <td><code>arm</code></td>
</tr>
<tr>
<td></td><td><code>android</code></td> <td><code>arm64</code></td>
</tr>
<tr>
<td></td><td><code>darwin</code></td> <td><code>amd64</code></td>
</tr>
<tr>
<td></td><td><code>darwin</code></td> <td><code>arm64</code></td>
</tr>
<tr>
<td></td><td><code>dragonfly</code></td> <td><code>amd64</code></td>
</tr>
<tr>
<td></td><td><code>freebsd</code></td> <td><code>386</code></td>
</tr>
<tr>
<td></td><td><code>freebsd</code></td> <td><code>amd64</code></td>
</tr>
<tr>
<td></td><td><code>freebsd</code></td> <td><code>arm</code></td>
</tr>
<tr>
<td></td><td><code>illumos</code></td> <td><code>amd64</code></td>
</tr>
<tr>
<td></td><td><code>ios</code></td> <td><code>arm64</code></td>
</tr>
<tr>
<td></td><td><code>js</code></td> <td><code>wasm</code></td>
</tr>
<tr>
<td></td><td><code>linux</code></td> <td><code>386</code></td>
</tr>
<tr>
<td></td><td><code>linux</code></td> <td><code>amd64</code></td>
</tr>
<tr>
<td></td><td><code>linux</code></td> <td><code>arm</code></td>
</tr>
<tr>
<td></td><td><code>linux</code></td> <td><code>arm64</code></td>
</tr>
<tr>
<td></td><td><code>linux</code></td> <td><code>ppc64</code></td>
</tr>
<tr>
<td></td><td><code>linux</code></td> <td><code>ppc64le</code></td>
</tr>
<tr>
<td></td><td><code>linux</code></td> <td><code>mips</code></td>
</tr>
<tr>
<td></td><td><code>linux</code></td> <td><code>mipsle</code></td>
</tr>
<tr>
<td></td><td><code>linux</code></td> <td><code>mips64</code></td>
</tr>
<tr>
<td></td><td><code>linux</code></td> <td><code>mips64le</code></td>
</tr>
<tr>
<td></td><td><code>linux</code></td> <td><code>riscv64</code></td>
</tr>
<tr>
<td></td><td><code>linux</code></td> <td><code>s390x</code></td>
</tr>
<tr>
<td></td><td><code>netbsd</code></td> <td><code>386</code></td>
</tr>
<tr>
<td></td><td><code>netbsd</code></td> <td><code>amd64</code></td>
</tr>
<tr>
<td></td><td><code>netbsd</code></td> <td><code>arm</code></td>
</tr>
<tr>
<td></td><td><code>openbsd</code></td> <td><code>386</code></td>
</tr>
<tr>
<td></td><td><code>openbsd</code></td> <td><code>amd64</code></td>
</tr>
<tr>
<td></td><td><code>openbsd</code></td> <td><code>arm</code></td>
</tr>
<tr>
<td></td><td><code>openbsd</code></td> <td><code>arm64</code></td>
</tr>
<tr>
<td></td><td><code>plan9</code></td> <td><code>386</code></td>
</tr>
<tr>
<td></td><td><code>plan9</code></td> <td><code>amd64</code></td>
</tr>
<tr>
<td></td><td><code>plan9</code></td> <td><code>arm</code></td>
</tr>
<tr>
<td></td><td><code>solaris</code></td> <td><code>amd64</code></td>
</tr>
<tr>
<td></td><td><code>windows</code></td> <td><code>386</code></td>
</tr>
<tr>
<td></td><td><code>windows</code></td> <td><code>amd64</code></td>
</tr>
</table>
<br>
<li><code>$GOHOSTOS</code> and <code>$GOHOSTARCH</code>
<p>
The name of the host operating system and compilation architecture.
These default to the local system's operating system and
architecture.
</p>
</li>
<p>
Valid choices are the same as for <code>$GOOS</code> and
<code>$GOARCH</code>, listed above.
The specified values must be compatible with the local system.
For example, you should not set <code>$GOHOSTARCH</code> to
<code>arm</code> on an x86 system.
</p>
<li><code>$GO386</code> (for <code>386</code> only, defaults to <code>sse2</code>)
<p>
This variable controls how gc implements floating point computations.
</p>
<ul>
<li><code>GO386=softfloat</code>: use software floating point operations; should support all x86 chips (Pentium MMX or later).</li>
<li><code>GO386=sse2</code>: use SSE2 for floating point operations; has better performance but only available on Pentium 4/Opteron/Athlon 64 or later.</li>
</ul>
</li>
<li><code>$GOARM</code> (for <code>arm</code> only; default is auto-detected if building
on the target processor, 6 if not)
<p>
This sets the ARM floating point co-processor architecture version the run-time
should target. If you are compiling on the target system, its value will be auto-detected.
</p>
<ul>
<li><code>GOARM=5</code>: use software floating point; when CPU doesn't have VFP co-processor</li>
<li><code>GOARM=6</code>: use VFPv1 only; default if cross compiling; usually ARM11 or better cores (VFPv2 or better is also supported)</li>
<li><code>GOARM=7</code>: use VFPv3; usually Cortex-A cores</li>
</ul>
<p>
If in doubt, leave this variable unset, and adjust it if required
when you first run the Go executable.
The <a href="//golang.org/wiki/GoArm">GoARM</a> page
on the <a href="//golang.org/wiki">Go community wiki</a>
contains further details regarding Go's ARM support.
</p>
</li>
<li><code>$GOMIPS</code> (for <code>mips</code> and <code>mipsle</code> only) <br> <code>$GOMIPS64</code> (for <code>mips64</code> and <code>mips64le</code> only)
<p>
These variables set whether to use floating point instructions. Set to "<code>hardfloat</code>" to use floating point instructions; this is the default. Set to "<code>softfloat</code>" to use soft floating point.
</p>
</li>
<li><code>$GOPPC64</code> (for <code>ppc64</code> and <code>ppc64le</code> only)
<p>
This variable sets the processor level (i.e. Instruction Set Architecture version)
for which the compiler will target. The default is <code>power8</code>.
</p>
<ul>
<li><code>GOPPC64=power8</code>: generate ISA v2.07 instructions</li>
<li><code>GOPPC64=power9</code>: generate ISA v3.00 instructions</li>
</ul>
</li>
<li><code>$GOWASM</code> (for <code>wasm</code> only)
<p>
This variable is a comma separated list of <a href="https://github.com/WebAssembly/proposals">experimental WebAssembly features</a> that the compiled WebAssembly binary is allowed to use.
The default is to use no experimental features.
</p>
<ul>
<li><code>GOWASM=satconv</code>: generate <a href="https://github.com/WebAssembly/nontrapping-float-to-int-conversions/blob/master/proposals/nontrapping-float-to-int-conversion/Overview.md">saturating (non-trapping) float-to-int conversions</a></li>
<li><code>GOWASM=signext</code>: generate <a href="https://github.com/WebAssembly/sign-extension-ops/blob/master/proposals/sign-extension-ops/Overview.md">sign-extension operators</a></li>
</ul>
</li>
</ul>
<p>
Note that <code>$GOARCH</code> and <code>$GOOS</code> identify the
<em>target</em> environment, not the environment you are running on.
In effect, you are always cross-compiling.
By architecture, we mean the kind of binaries
that the target environment can run:
an x86-64 system running a 32-bit-only operating system
must set <code>GOARCH</code> to <code>386</code>,
not <code>amd64</code>.
</p>
<p>
If you choose to override the defaults,
set these variables in your shell profile (<code>$HOME/.bashrc</code>,
<code>$HOME/.profile</code>, or equivalent). The settings might look
something like this:
</p>
<pre>
export GOARCH=amd64
export GOOS=linux
</pre>
<p>
although, to reiterate, none of these variables needs to be set to build,
install, and develop the Go tree.
</p>

View file

@ -1,315 +0,0 @@
<!--{
"Title": "Getting Started",
"Path": "/doc/install"
}-->
<div class="hideFromDownload">
<h2 id="download">Download the Go distribution</h2>
<p>
<a href="/dl/" id="start" class="download">
<span class="big">Download Go</span>
<span class="desc">Click here to visit the downloads page</span>
</a>
</p>
<p>
<a href="/dl/" target="_blank">Official binary
distributions</a> are available for the FreeBSD (release 10-STABLE and above),
Linux, macOS (10.11 and above), and Windows operating systems and
the 32-bit (<code>386</code>) and 64-bit (<code>amd64</code>) x86 processor
architectures.
</p>
<p>
If a binary distribution is not available for your combination of operating
system and architecture, try
<a href="/doc/install/source">installing from source</a> or
<a href="/doc/install/gccgo">installing gccgo instead of gc</a>.
</p>
<h2 id="requirements">System requirements</h2>
<p>
Go <a href="/dl/">binary distributions</a> are available for these supported operating systems and architectures.
Please ensure your system meets these requirements before proceeding.
If your OS or architecture is not on the list, you may be able to
<a href="/doc/install/source">install from source</a> or
<a href="/doc/install/gccgo">use gccgo instead</a>.
</p>
<table class="codetable" frame="border" summary="requirements">
<tr>
<th align="center">Operating system</th>
<th align="center">Architectures</th>
<th align="center">Notes</th>
</tr>
<tr><td colspan="3"><hr></td></tr>
<tr><td>FreeBSD 10.3 or later</td> <td>amd64, 386</td> <td>Debian GNU/kFreeBSD not supported</td></tr>
<tr valign='top'><td>Linux 2.6.23 or later with glibc</td> <td>amd64, 386, arm, arm64,<br>s390x, ppc64le</td> <td>CentOS/RHEL 5.x not supported.<br>Install from source for other libc.</td></tr>
<tr><td>macOS 10.11 or later</td> <td>amd64</td> <td>use the clang or gcc<sup>&#8224;</sup> that comes with Xcode<sup>&#8225;</sup> for <code>cgo</code> support</td></tr>
<tr valign='top'><td>Windows 7, Server 2008R2 or later</td> <td>amd64, 386</td> <td>use MinGW (<code>386</code>) or MinGW-W64 (<code>amd64</code>) gcc<sup>&#8224;</sup>.<br>No need for cygwin or msys.</td></tr>
</table>
<p>
<sup>&#8224;</sup>A C compiler is required only if you plan to use
<a href="/cmd/cgo">cgo</a>.<br/>
<sup>&#8225;</sup>You only need to install the command line tools for
<a href="https://developer.apple.com/Xcode/">Xcode</a>. If you have already
installed Xcode 4.3+, you can install it from the Components tab of the
Downloads preferences panel.
</p>
</div><!-- hideFromDownload -->
<h2 id="install">Install the Go tools</h2>
<p>
If you are upgrading from an older version of Go you must
first <a href="#uninstall">remove the existing version</a>.
</p>
<div id="tarballInstructions">
<h3 id="tarball">Linux, macOS, and FreeBSD tarballs</h3>
<p>
<a href="/dl/">Download the archive</a>
and extract it into <code>/usr/local</code>, creating a Go tree in
<code>/usr/local/go</code>. For example:
</p>
<pre>
tar -C /usr/local -xzf <span class="downloadFilename">go$VERSION.$OS-$ARCH.tar.gz</span>
</pre>
<p class="hideFromDownload">
Choose the archive file appropriate for your installation.
For instance, if you are installing Go version 1.2.1 for 64-bit x86 on Linux,
the archive you want is called <code>go1.2.1.linux-amd64.tar.gz</code>.
</p>
<p>
(Typically these commands must be run as root or through <code>sudo</code>.)
</p>
<p>
Add <code>/usr/local/go/bin</code> to the <code>PATH</code> environment
variable. You can do this by adding this line to your <code>/etc/profile</code>
(for a system-wide installation) or <code>$HOME/.profile</code>:
</p>
<pre>
export PATH=$PATH:/usr/local/go/bin
</pre>
<p>
<b>Note</b>: changes made to a <code>profile</code> 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>
</div><!-- tarballInstructions -->
<div id="darwinPackageInstructions">
<h3 id="macos"><div id="osx"></div>macOS package installer</h3>
<p>
<a href="/dl/">Download the package file</a>,
open it, and follow the prompts to install the Go tools.
The package installs the Go distribution to <code>/usr/local/go</code>.
</p>
<p>
The package should put the <code>/usr/local/go/bin</code> directory in your
<code>PATH</code> environment variable. You may need to restart any open
Terminal sessions for the change to take effect.
</p>
</div><!-- darwinPackageInstructions -->
<div id="windowsInstructions">
<h3 id="windows">Windows</h3>
<p class="hideFromDownload">
The Go project provides two installation options for Windows users
(besides <a href="/doc/install/source">installing from source</a>):
a zip archive that requires you to set some environment variables and an
MSI installer that configures your installation automatically.
</p>
<div id="windowsInstallerInstructions">
<h4 id="windows_msi">MSI installer</h4>
<p>
Open the <a href="/dl/">MSI file</a>
and follow the prompts to install the Go tools.
By default, the installer puts the Go distribution in <code>c:\Go</code>.
</p>
<p>
The installer should put the <code>c:\Go\bin</code> directory in your
<code>PATH</code> environment variable. You may need to restart any open
command prompts for the change to take effect.
</p>
</div><!-- windowsInstallerInstructions -->
<div id="windowsZipInstructions">
<h4 id="windows_zip">Zip archive</h4>
<p>
<a href="/dl/">Download the zip file</a> and extract it into the directory of your choice (we suggest <code>c:\Go</code>).
</p>
<p>
Add the <code>bin</code> subdirectory of your Go root (for example, <code>c:\Go\bin</code>) to your <code>PATH</code> environment variable.
</p>
</div><!-- windowsZipInstructions -->
<h4 id="windows_env">Setting environment variables under Windows</h4>
<p>
Under Windows, you may set environment variables through the "Environment
Variables" button on the "Advanced" tab of the "System" control panel. Some
versions of Windows provide this control panel through the "Advanced System
Settings" option inside the "System" control panel.
</p>
</div><!-- windowsInstructions -->
<h2 id="testing">Test your installation</h2>
<p>
Check that Go is installed correctly by building a simple program, as follows.
</p>
<p>
Create a file named <code>hello.go</code> that looks like:
</p>
<pre>
package main
import "fmt"
func main() {
fmt.Printf("hello, world\n")
}
</pre>
<p>
Then build it with the <code>go</code> tool:
</p>
<pre class="testUnix">
$ <b>go build hello.go</b>
</pre>
<pre class="testWindows">
C:\Users\Gopher\go\src\hello&gt; <b>go build hello.go</b>
</pre>
<p>
The command above will build an executable named
<code class="testUnix">hello</code><code class="testWindows">hello.exe</code>
in the current directory alongside your source code.
Execute it to see the greeting:
</p>
<pre class="testUnix">
$ <b>./hello</b>
hello, world
</pre>
<pre class="testWindows">
C:\Users\Gopher\go\src\hello&gt; <b>hello</b>
hello, world
</pre>
<p>
If you see the "hello, world" message then your Go installation is working.
</p>
<p>
Before rushing off to write Go code please read the
<a href="/doc/code.html">How to Write Go Code</a> document,
which describes some essential concepts about using the Go tools.
</p>
<h2 id="extra_versions">Installing extra Go versions</h2>
<p>
It may be useful to have multiple Go versions installed on the same machine, for
example, to ensure that a package's tests pass on multiple Go versions.
Once you have one Go version installed, you can install another (such as 1.10.7)
as follows:
</p>
<pre>
$ go get golang.org/dl/go1.10.7
$ go1.10.7 download
</pre>
<p>
The newly downloaded version can be used like <code>go</code>:
</p>
<pre>
$ go1.10.7 version
go version go1.10.7 linux/amd64
</pre>
<p>
All Go versions available via this method are listed on
<a href="https://godoc.org/golang.org/dl#pkg-subdirectories">the download page</a>.
You can find where each of these extra Go versions is installed by looking
at its <code>GOROOT</code>; for example, <code>go1.10.7 env GOROOT</code>.
To uninstall a downloaded version, just remove its <code>GOROOT</code> directory
and the <code>goX.Y.Z</code> binary.
</p>
<h2 id="uninstall">Uninstalling Go</h2>
<p>
To remove an existing Go installation from your system delete the
<code>go</code> directory. This is usually <code>/usr/local/go</code>
under Linux, macOS, and FreeBSD or <code>c:\Go</code>
under Windows.
</p>
<p>
You should also remove the Go <code>bin</code> directory from your
<code>PATH</code> environment variable.
Under Linux and FreeBSD you should edit <code>/etc/profile</code> or
<code>$HOME/.profile</code>.
If you installed Go with the <a href="#macos">macOS package</a> then you
should remove the <code>/etc/paths.d/go</code> file.
Windows users should read the section about <a href="#windows_env">setting
environment variables under Windows</a>.
</p>
<h2 id="help">Getting help</h2>
<p>
For help, see the <a href="/help/">list of Go mailing lists, forums, and places to chat</a>.
</p>
<p>
Report bugs either by running “<b><code>go</code> <code>bug</code></b>”, or
manually at the <a href="https://golang.org/issue">Go issue tracker</a>.
</p>