]> Cypherpunks.ru repositories - gostls13.git/blob - doc/install.html
internal/poll: if copy_file_range returns 0, assume it failed
[gostls13.git] / doc / install.html
1 <!--{
2         "Title": "Getting Started",
3         "Path":  "/doc/install"
4 }-->
5
6 <div class="hideFromDownload">
7
8 <h2 id="download">Download the Go distribution</h2>
9
10 <p>
11 <a href="/dl/" id="start" class="download">
12 <span class="big">Download Go</span>
13 <span class="desc">Click here to visit the downloads page</span>
14 </a>
15 </p>
16
17 <p>
18 <a href="/dl/" target="_blank">Official binary
19 distributions</a> are available for the FreeBSD (release 10-STABLE and above),
20 Linux, macOS (10.11 and above), and Windows operating systems and
21 the 32-bit (<code>386</code>) and 64-bit (<code>amd64</code>) x86 processor
22 architectures.
23 </p>
24
25 <p>
26 If a binary distribution is not available for your combination of operating
27 system and architecture, try
28 <a href="/doc/install/source">installing from source</a> or
29 <a href="/doc/install/gccgo">installing gccgo instead of gc</a>.
30 </p>
31
32
33 <h2 id="requirements">System requirements</h2>
34
35 <p>
36 Go <a href="/dl/">binary distributions</a> are available for these supported operating systems and architectures.
37 Please ensure your system meets these requirements before proceeding.
38 If your OS or architecture is not on the list, you may be able to
39 <a href="/doc/install/source">install from source</a> or
40 <a href="/doc/install/gccgo">use gccgo instead</a>.
41 </p>
42
43 <table class="codetable" frame="border" summary="requirements">
44 <tr>
45 <th align="center">Operating system</th>
46 <th align="center">Architectures</th>
47 <th align="center">Notes</th>
48 </tr>
49 <tr><td colspan="3"><hr></td></tr>
50 <tr><td>FreeBSD 10.3 or later</td> <td>amd64, 386</td> <td>Debian GNU/kFreeBSD not supported</td></tr>
51 <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>
52 <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>
53 <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>
54 </table>
55
56 <p>
57 <sup>&#8224;</sup>A C compiler is required only if you plan to use
58 <a href="/cmd/cgo">cgo</a>.<br/>
59 <sup>&#8225;</sup>You only need to install the command line tools for
60 <a href="https://developer.apple.com/Xcode/">Xcode</a>. If you have already
61 installed Xcode 4.3+, you can install it from the Components tab of the
62 Downloads preferences panel.
63 </p>
64
65 </div><!-- hideFromDownload -->
66
67
68 <h2 id="install">Install the Go tools</h2>
69
70 <p>
71 If you are upgrading from an older version of Go you must
72 first <a href="#uninstall">remove the existing version</a>.
73 </p>
74
75 <div id="tarballInstructions">
76
77 <h3 id="tarball">Linux, macOS, and FreeBSD tarballs</h3>
78
79 <p>
80 <a href="/dl/">Download the archive</a>
81 and extract it into <code>/usr/local</code>, creating a Go tree in
82 <code>/usr/local/go</code>. For example:
83 </p>
84
85 <pre>
86 tar -C /usr/local -xzf <span class="downloadFilename">go$VERSION.$OS-$ARCH.tar.gz</span>
87 </pre>
88
89 <p class="hideFromDownload">
90 Choose the archive file appropriate for your installation.
91 For instance, if you are installing Go version 1.2.1 for 64-bit x86 on Linux,
92 the archive you want is called <code>go1.2.1.linux-amd64.tar.gz</code>.
93 </p>
94
95 <p>
96 (Typically these commands must be run as root or through <code>sudo</code>.)
97 </p>
98
99 <p>
100 Add <code>/usr/local/go/bin</code> to the <code>PATH</code> environment
101 variable. You can do this by adding this line to your <code>/etc/profile</code>
102 (for a system-wide installation) or <code>$HOME/.profile</code>:
103 </p>
104
105 <pre>
106 export PATH=$PATH:/usr/local/go/bin
107 </pre>
108
109 <p>
110 <b>Note</b>: changes made to a <code>profile</code> file may not apply until the
111 next time you log into your computer.
112 To apply the changes immediately, just run the shell commands directly
113 or execute them from the profile using a command such as
114 <code>source $HOME/.profile</code>.
115 </p>
116
117 </div><!-- tarballInstructions -->
118
119 <div id="darwinPackageInstructions">
120
121 <h3 id="macos"><div id="osx"></div>macOS package installer</h3>
122
123 <p>
124 <a href="/dl/">Download the package file</a>,
125 open it, and follow the prompts to install the Go tools.
126 The package installs the Go distribution to <code>/usr/local/go</code>.
127 </p>
128
129 <p>
130 The package should put the <code>/usr/local/go/bin</code> directory in your
131 <code>PATH</code> environment variable. You may need to restart any open
132 Terminal sessions for the change to take effect.
133 </p>
134
135 </div><!-- darwinPackageInstructions -->
136
137 <div id="windowsInstructions">
138
139 <h3 id="windows">Windows</h3>
140
141 <p class="hideFromDownload">
142 The Go project provides two installation options for Windows users
143 (besides <a href="/doc/install/source">installing from source</a>):
144 a zip archive that requires you to set some environment variables and an
145 MSI installer that configures your installation automatically.
146 </p>
147
148 <div id="windowsInstallerInstructions">
149
150 <h4 id="windows_msi">MSI installer</h4>
151
152 <p>
153 Open the <a href="/dl/">MSI file</a>
154 and follow the prompts to install the Go tools.
155 By default, the installer puts the Go distribution in <code>c:\Go</code>.
156 </p>
157
158 <p>
159 The 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
161 command prompts for the change to take effect.
162 </p>
163
164 </div><!-- windowsInstallerInstructions -->
165
166 <div id="windowsZipInstructions">
167
168 <h4 id="windows_zip">Zip archive</h4>
169
170 <p>
171 <a href="/dl/">Download the zip file</a> and extract it into the directory of your choice (we suggest <code>c:\Go</code>).
172 </p>
173
174 <p>
175 Add the <code>bin</code> subdirectory of your Go root (for example, <code>c:\Go\bin</code>) to your <code>PATH</code> environment variable.
176 </p>
177
178 </div><!-- windowsZipInstructions -->
179
180 <h4 id="windows_env">Setting environment variables under Windows</h4>
181
182 <p>
183 Under Windows, you may set environment variables through the "Environment
184 Variables" button on the "Advanced" tab of the "System" control panel. Some
185 versions of Windows provide this control panel through the "Advanced System
186 Settings" option inside the "System" control panel.
187 </p>
188
189 </div><!-- windowsInstructions -->
190
191
192 <h2 id="testing">Test your installation</h2>
193
194 <p>
195 Check that Go is installed correctly by building a simple program, as follows.
196 </p>
197
198 <p>
199 Create a file named <code>hello.go</code> that looks like:
200 </p>
201
202 <pre>
203 package main
204
205 import "fmt"
206
207 func main() {
208         fmt.Printf("hello, world\n")
209 }
210 </pre>
211
212 <p>
213 Then build it with the <code>go</code> tool:
214 </p>
215
216 <pre class="testUnix">
217 $ <b>go build hello.go</b>
218 </pre>
219
220 <pre class="testWindows">
221 C:\Users\Gopher\go\src\hello&gt; <b>go build hello.go</b>
222 </pre>
223
224 <p>
225 The command above will build an executable named
226 <code class="testUnix">hello</code><code class="testWindows">hello.exe</code>
227 in the current directory alongside your source code.
228 Execute it to see the greeting:
229 </p>
230
231 <pre class="testUnix">
232 $ <b>./hello</b>
233 hello, world
234 </pre>
235
236 <pre class="testWindows">
237 C:\Users\Gopher\go\src\hello&gt; <b>hello</b>
238 hello, world
239 </pre>
240
241 <p>
242 If you see the "hello, world" message then your Go installation is working.
243 </p>
244
245 <p>
246 Before rushing off to write Go code please read the
247 <a href="/doc/code.html">How to Write Go Code</a> document,
248 which describes some essential concepts about using the Go tools.
249 </p>
250
251
252 <h2 id="extra_versions">Installing extra Go versions</h2>
253
254 <p>
255 It may be useful to have multiple Go versions installed on the same machine, for
256 example, to ensure that a package's tests pass on multiple Go versions.
257 Once you have one Go version installed, you can install another (such as 1.10.7)
258 as follows:
259 </p>
260
261 <pre>
262 $ go get golang.org/dl/go1.10.7
263 $ go1.10.7 download
264 </pre>
265
266 <p>
267 The newly downloaded version can be used like <code>go</code>:
268 </p>
269
270 <pre>
271 $ go1.10.7 version
272 go version go1.10.7 linux/amd64
273 </pre>
274
275 <p>
276 All Go versions available via this method are listed on
277 <a href="https://godoc.org/golang.org/dl#pkg-subdirectories">the download page</a>.
278 You can find where each of these extra Go versions is installed by looking
279 at its <code>GOROOT</code>; for example, <code>go1.10.7 env GOROOT</code>.
280 To uninstall a downloaded version, just remove its <code>GOROOT</code> directory
281 and the <code>goX.Y.Z</code> binary.
282 </p>
283
284
285 <h2 id="uninstall">Uninstalling Go</h2>
286
287 <p>
288 To remove an existing Go installation from your system delete the
289 <code>go</code> directory. This is usually <code>/usr/local/go</code>
290 under Linux, macOS, and FreeBSD or <code>c:\Go</code>
291 under Windows.
292 </p>
293
294 <p>
295 You should also remove the Go <code>bin</code> directory from your
296 <code>PATH</code> environment variable.
297 Under Linux and FreeBSD you should edit <code>/etc/profile</code> or
298 <code>$HOME/.profile</code>.
299 If you installed Go with the <a href="#macos">macOS package</a> then you
300 should remove the <code>/etc/paths.d/go</code> file.
301 Windows users should read the section about <a href="#windows_env">setting
302 environment variables under Windows</a>.
303 </p>
304
305
306 <h2 id="help">Getting help</h2>
307
308 <p>
309   For help, see the <a href="/help/">list of Go mailing lists, forums, and places to chat</a>.
310 </p>
311
312 <p>
313   Report bugs either by running “<b><code>go</code> <code>bug</code></b>”, or
314   manually at the <a href="https://golang.org/issue">Go issue tracker</a>.
315 </p>