blob: 9561fdde21063c4e7b1995fa53171c74cc929960 [file] [log] [blame]
Brent Austinba3052e2015-04-21 16:08:23 -07001<!--{
2 "Title": "Getting Started",
3 "Path": "/doc/install"
4}-->
5
6<h2 id="download">Download the Go distribution</h2>
7
8<p>
9<a href="https://golang.org/dl/" id="start" class="download" target="_blank">
10<span class="big">Download Go</span>
11<span class="desc">Click here to visit the downloads page</span>
12</a>
13</p>
14
15<p>
16<a href="https://golang.org/dl/" target="_blank">Official binary
17distributions</a> are available for the FreeBSD (release 8 and above), Linux, Mac OS X (Snow Leopard
18and above), and Windows operating systems and the 32-bit (<code>386</code>) and
1964-bit (<code>amd64</code>) x86 processor architectures.
20</p>
21
22<p>
23If a binary distribution is not available for your combination of operating
24system and architecture, try
25<a href="/doc/install/source">installing from source</a> or
26<a href="/doc/install/gccgo">installing gccgo instead of gc</a>.
27</p>
28
29
30<h2 id="requirements">System requirements</h2>
31
32<p>
33The <code>gc</code> compiler supports the following operating systems and
34architectures. Please ensure your system meets these requirements before
35proceeding. If your OS or architecture is not on the list, it's possible that
36<code>gccgo</code> might support your setup; see
37<a href="/doc/install/gccgo">Setting up and using gccgo</a> for details.
38</p>
39
40<table class="codetable" frame="border" summary="requirements">
41<tr>
42<th align="center">Operating system</th>
43<th align="center">Architectures</th>
44<th align="center">Notes</th>
45</tr>
46<tr><td colspan="3"><hr></td></tr>
47<tr><td>FreeBSD 8 or later</td> <td>amd64, 386, arm</td> <td>Debian GNU/kFreeBSD not supported; FreeBSD/ARM needs FreeBSD 10 or later</td></tr>
48<tr><td>Linux 2.6.23 or later with glibc</td> <td>amd64, 386, arm</td> <td>CentOS/RHEL 5.x not supported; no binary distribution for ARM yet</td></tr>
49<tr><td>Mac OS X 10.6 or later</td> <td>amd64, 386</td> <td>use the gcc<sup>&#8224;</sup> that comes with Xcode<sup>&#8225;</sup></td></tr>
50<tr><td>Windows XP or later</td> <td>amd64, 386</td> <td>use MinGW gcc<sup>&#8224;</sup>. No need for cygwin or msys.</td></tr>
51</table>
52
53<p>
54<sup>&#8224;</sup><code>gcc</code> is required only if you plan to use
55<a href="/cmd/cgo">cgo</a>.<br/>
56<sup>&#8225;</sup>You only need to install the command line tools for
57<a href="http://developer.apple.com/Xcode/">Xcode</a>. If you have already
58installed Xcode 4.3+, you can install it from the Components tab of the
59Downloads preferences panel.
60</p>
61
62
63<h2 id="install">Install the Go tools</h2>
64
65<p>
66If you are upgrading from an older version of Go you must
67first <a href="#uninstall">remove the existing version</a>.
68</p>
69
70<h3 id="tarball">Linux, Mac OS X, and FreeBSD tarballs</h3>
71
72<p>
73<a href="https://golang.org/dl/">Download the archive</a>
74and extract it into <code>/usr/local</code>, creating a Go tree in
75<code>/usr/local/go</code>. For example:
76</p>
77
78<pre>
79tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz
80</pre>
81
82<p>
83Choose the archive file appropriate for your installation.
84For instance, if you are installing Go version 1.2.1 for 64-bit x86 on Linux,
85the archive you want is called <code>go1.2.1.linux-amd64.tar.gz</code>.
86</p>
87
88<p>
89(Typically these commands must be run as root or through <code>sudo</code>.)
90</p>
91
92<p>
93Add <code>/usr/local/go/bin</code> to the <code>PATH</code> environment
94variable. You can do this by adding this line to your <code>/etc/profile</code>
95(for a system-wide installation) or <code>$HOME/.profile</code>:
96</p>
97
98<pre>
99export PATH=$PATH:/usr/local/go/bin
100</pre>
101
102<h4 id="tarball_non_standard">Installing to a custom location</h4>
103
104<p>
105The Go binary distributions assume they will be installed in
106<code>/usr/local/go</code> (or <code>c:\Go</code> under Windows),
107but it is possible to install the Go tools to a different location.
108In this case you must set the <code>GOROOT</code> environment variable
109to point to the directory in which it was installed.
110</p>
111
112<p>
113For example, if you installed Go to your home directory you should add the
114following commands to <code>$HOME/.profile</code>:
115</p>
116
117<pre>
118export GOROOT=$HOME/go
119export PATH=$PATH:$GOROOT/bin
120</pre>
121
122<p>
123<b>Note</b>: <code>GOROOT</code> must be set only when installing to a custom
124location.
125</p>
126
127<h3 id="osx">Mac OS X package installer</h3>
128
129<p>
130<a href="https://golang.org/dl/">Download the package file</a>,
131open it, and follow the prompts to install the Go tools.
132The package installs the Go distribution to <code>/usr/local/go</code>.
133</p>
134
135<p>
136The package should put the <code>/usr/local/go/bin</code> directory in your
137<code>PATH</code> environment variable. You may need to restart any open
138Terminal sessions for the change to take effect.
139</p>
140
141<h3 id="windows">Windows</h3>
142
143<p>
144The Go project provides two installation options for Windows users
145(besides <a href="/doc/install/source">installing from source</a>):
146a zip archive that requires you to set some environment variables and an
147MSI installer that configures your installation automatically.
148</p>
149
150<h4 id="windows_msi">MSI installer</h4>
151
152<p>
153Open the <a href="https://golang.org/dl/">MSI file</a>
154and follow the prompts to install the Go tools.
155By default, the installer puts the Go distribution in <code>c:\Go</code>.
156</p>
157
158<p>
159The installer should put the <code>c:\Go\bin</code> directory in your
160<code>PATH</code> environment variable. You may need to restart any open
161command prompts for the change to take effect.
162</p>
163
164<h4 id="windows_zip">Zip archive</h4>
165
166<p>
167<a href="https://golang.org/dl/">Download the zip file</a> and extract it into the directory of your choice (we suggest <code>c:\Go</code>).
168</p>
169
170<p>
171If you chose a directory other than <code>c:\Go</code>,
172you must set the <code>GOROOT</code> environment variable to your chosen path.
173</p>
174
175<p>
176Add the <code>bin</code> subdirectory of your Go root (for example, <code>c:\Go\bin</code>) to your <code>PATH</code> environment variable.
177</p>
178
179<h4 id="windows_env">Setting environment variables under Windows</h4>
180
181<p>
182Under Windows, you may set environment variables through the "Environment
183Variables" button on the "Advanced" tab of the "System" control panel. Some
184versions of Windows provide this control panel through the "Advanced System
185Settings" option inside the "System" control panel.
186</p>
187
188
189<h2 id="testing">Test your installation</h2>
190
191<p>
192Check that Go is installed correctly by building a simple program, as follows.
193</p>
194
195<p>
196Create a file named <code>hello.go</code> and put the following program in it:
197</p>
198
199<pre>
200package main
201
202import "fmt"
203
204func main() {
205 fmt.Printf("hello, world\n")
206}
207</pre>
208
209<p>
210Then run it with the <code>go</code> tool:
211</p>
212
213<pre>
214$ go run hello.go
215hello, world
216</pre>
217
218<p>
219If you see the "hello, world" message then your Go installation is working.
220</p>
221
222
223<h2 id="gopath">Set up your work environment</h2>
224
225<p>
226You're almost done.
227You just need to set up your environment.
228</p>
229
230<p>
231Read the <a href="/doc/code.html">How to Write Go Code</a> document,
232which provides <b>essential setup instructions</b> for using the Go tools.
233</p>
234
235
236<h2 id="uninstall">Uninstalling Go</h2>
237
238<p>
239To remove an existing Go installation from your system delete the
240<code>go</code> directory. This is usually <code>/usr/local/go</code>
241under Linux, Mac OS X, and FreeBSD or <code>c:\Go</code>
242under Windows.
243</p>
244
245<p>
246You should also remove the Go <code>bin</code> directory from your
247<code>PATH</code> environment variable.
248Under Linux and FreeBSD you should edit <code>/etc/profile</code> or
249<code>$HOME/.profile</code>.
250If you installed Go with the <a href="#osx">Mac OS X package</a> then you
251should remove the <code>/etc/paths.d/go</code> file.
252Windows users should read the section about <a href="#windows_env">setting
253environment variables under Windows</a>.
254</p>
255
256
257<h2 id="help">Getting help</h2>
258
259<p>
260For real-time help, ask the helpful gophers in <code>#go-nuts</code> on the
261<a href="http://freenode.net/">Freenode</a> IRC server.
262</p>
263
264<p>
265The official mailing list for discussion of the Go language is
266<a href="//groups.google.com/group/golang-nuts">Go Nuts</a>.
267</p>
268
269<p>
270Report bugs using the
271<a href="//golang.org/issue">Go issue tracker</a>.
272</p>