install-source.html 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659
  1. <!--{
  2. "Title": "Installing Go from source",
  3. "Path": "/doc/install/source"
  4. }-->
  5. <h2 id="introduction">Introduction</h2>
  6. <p>
  7. Go is an open source project, distributed under a
  8. <a href="/LICENSE">BSD-style license</a>.
  9. This document explains how to check out the sources,
  10. build them on your own machine, and run them.
  11. </p>
  12. <p>
  13. Most users don't need to do this, and will instead install
  14. from precompiled binary packages as described in
  15. <a href="/doc/install">Getting Started</a>,
  16. a much simpler process.
  17. If you want to help develop what goes into those precompiled
  18. packages, though, read on.
  19. </p>
  20. <div class="detail">
  21. <p>
  22. There are two official Go compiler tool chains.
  23. This document focuses on the <code>gc</code> Go
  24. compiler and tools.
  25. For information on how to work on <code>gccgo</code>, a more traditional
  26. compiler using the GCC back end, see
  27. <a href="/doc/install/gccgo">Setting up and using gccgo</a>.
  28. </p>
  29. <p>
  30. The Go compilers support eight instruction sets.
  31. There are important differences in the quality of the compilers for the different
  32. architectures.
  33. </p>
  34. <dl>
  35. <dt>
  36. <code>amd64</code> (also known as <code>x86-64</code>)
  37. </dt>
  38. <dd>
  39. A mature implementation.
  40. </dd>
  41. <dt>
  42. <code>386</code> (<code>x86</code> or <code>x86-32</code>)
  43. </dt>
  44. <dd>
  45. Comparable to the <code>amd64</code> port.
  46. </dd>
  47. <dt>
  48. <code>arm</code> (<code>ARM</code>)
  49. </dt>
  50. <dd>
  51. Supports Linux, FreeBSD, NetBSD, OpenBSD and Darwin binaries. Less widely used than the other ports.
  52. </dd>
  53. <dt>
  54. <code>arm64</code> (<code>AArch64</code>)
  55. </dt>
  56. <dd>
  57. Supports Linux and Darwin binaries. New in 1.5 and not as well exercised as other ports.
  58. </dd>
  59. <dt>
  60. <code>ppc64, ppc64le</code> (64-bit PowerPC big- and little-endian)
  61. </dt>
  62. <dd>
  63. Supports Linux binaries. New in 1.5 and not as well exercised as other ports.
  64. </dd>
  65. <dt>
  66. <code>mips, mipsle</code> (32-bit MIPS big- and little-endian)
  67. </dt>
  68. <dd>
  69. Supports Linux binaries. New in 1.8 and not as well exercised as other ports.
  70. </dd>
  71. <dt>
  72. <code>mips64, mips64le</code> (64-bit MIPS big- and little-endian)
  73. </dt>
  74. <dd>
  75. Supports Linux binaries. New in 1.6 and not as well exercised as other ports.
  76. </dd>
  77. <dt>
  78. <code>s390x</code> (IBM System z)
  79. </dt>
  80. <dd>
  81. Supports Linux binaries. New in 1.7 and not as well exercised as other ports.
  82. </dd>
  83. </dl>
  84. <p>
  85. Except for things like low-level operating system interface code, the run-time
  86. support is the same in all ports and includes a mark-and-sweep garbage
  87. collector, efficient array and string slicing, and support for efficient
  88. goroutines, such as stacks that grow and shrink on demand.
  89. </p>
  90. <p>
  91. The compilers can target the DragonFly BSD, FreeBSD, Linux, NetBSD, OpenBSD,
  92. OS X (Darwin), Plan 9, Solaris and Windows operating systems.
  93. The full set of supported combinations is listed in the discussion of
  94. <a href="#environment">environment variables</a> below.
  95. </p>
  96. <p>
  97. See the main installation page for the <a href="/doc/install#requirements">overall system requirements</a>.
  98. The following additional constraints apply to systems that can be built only from source:
  99. </p>
  100. <ul>
  101. <li>For Linux on PowerPC 64-bit, the minimum supported kernel version is 2.6.37, meaning that
  102. Go does not support CentOS 6 on these systems.
  103. </li>
  104. </ul>
  105. </div>
  106. <h2 id="go14">Install Go compiler binaries</h2>
  107. <p>
  108. The Go tool chain is written in Go. To build it, you need a Go compiler installed.
  109. The scripts that do the initial build of the tools look for an existing Go tool
  110. chain in <code>$GOROOT_BOOTSTRAP</code>.
  111. If unset, the default value of <code>GOROOT_BOOTSTRAP</code>
  112. is <code>$HOME/go1.4</code>.
  113. </p>
  114. <p>
  115. There are many options for the bootstrap tool chain.
  116. After obtaining one, set <code>GOROOT_BOOTSTRAP</code> to the
  117. directory containing the unpacked tree.
  118. For example, <code>$GOROOT_BOOTSTRAP/bin/go</code> should be
  119. the <code>go</code> command binary for the bootstrap tool chain.
  120. </p>
  121. <p>
  122. To use a binary release as a bootstrap tool chain, see
  123. <a href="/dl/">the downloads page</a> or use any other
  124. packaged Go distribution.
  125. </p>
  126. <p>
  127. To build a bootstrap tool chain from source, use
  128. either the git branch <code>release-branch.go1.4</code> or
  129. <a href="https://storage.googleapis.com/golang/go1.4-bootstrap-20170531.tar.gz">go1.4-bootstrap-20170531.tar.gz</a>,
  130. which contains the Go 1.4 source code plus accumulated fixes
  131. to keep the tools running on newer operating systems.
  132. (Go 1.4 was the last distribution in which the tool chain was written in C.)
  133. After unpacking the Go 1.4 source, <code>cd</code> to
  134. the <code>src</code> subdirectory and run <code>make.bash</code> (or,
  135. on Windows, <code>make.bat</code>).
  136. </p>
  137. <p>
  138. To cross-compile a bootstrap tool chain from source, which is
  139. necessary on systems Go 1.4 did not target (for
  140. example, <code>linux/ppc64le</code>), install Go on a different system
  141. and run <a href="/src/bootstrap.bash">bootstrap.bash</a>.
  142. </p>
  143. <p>
  144. When run as (for example)
  145. </p>
  146. <pre>
  147. $ GOOS=linux GOARCH=ppc64 ./bootstrap.bash
  148. </pre>
  149. <p>
  150. <code>bootstrap.bash</code> cross-compiles a toolchain for that <code>GOOS/GOARCH</code>
  151. combination, leaving the resulting tree in <code>../../go-${GOOS}-${GOARCH}-bootstrap</code>.
  152. That tree can be copied to a machine of the given target type
  153. and used as <code>GOROOT_BOOTSTRAP</code> to bootstrap a local build.
  154. </p>
  155. <p>
  156. To use gccgo as the bootstrap toolchain, you need to arrange
  157. for <code>$GOROOT_BOOTSTRAP/bin/go</code> to be the go tool that comes
  158. as part of gccgo 5. For example on Ubuntu Vivid:
  159. </p>
  160. <pre>
  161. $ sudo apt-get install gccgo-5
  162. $ sudo update-alternatives --set go /usr/bin/go-5
  163. $ GOROOT_BOOTSTRAP=/usr ./make.bash
  164. </pre>
  165. <h2 id="git">Install Git, if needed</h2>
  166. <p>
  167. To perform the next step you must have Git installed. (Check that you
  168. have a <code>git</code> command before proceeding.)
  169. </p>
  170. <p>
  171. If you do not have a working Git installation,
  172. follow the instructions on the
  173. <a href="http://git-scm.com/downloads">Git downloads</a> page.
  174. </p>
  175. <h2 id="ccompiler">(Optional) Install a C compiler</h2>
  176. <p>
  177. To build a Go installation
  178. with <code><a href="/cmd/cgo">cgo</a></code> support, which permits Go
  179. programs to import C libraries, a C compiler such as <code>gcc</code>
  180. or <code>clang</code> must be installed first. Do this using whatever
  181. installation method is standard on the system.
  182. </p>
  183. <p>
  184. To build without <code>cgo</code>, set the environment variable
  185. <code>CGO_ENABLED=0</code> before running <code>all.bash</code> or
  186. <code>make.bash</code>.
  187. </p>
  188. <h2 id="fetch">Fetch the repository</h2>
  189. <p>Go will install to a directory named <code>go</code>.
  190. Change to the directory that will be its parent
  191. and make sure the <code>go</code> directory does not exist.
  192. Then clone the repository and check out the latest release tag
  193. (<code class="versionTag">go1.8.1</code>, for example):</p>
  194. <pre>
  195. $ git clone https://go.googlesource.com/go
  196. $ cd go
  197. $ git checkout <span class="versionTag"><i>&lt;tag&gt;</i></span>
  198. </pre>
  199. <p class="whereTag">
  200. Where <code>&lt;tag&gt;</code> is the version string of the release.
  201. </p>
  202. <h2 id="head">(Optional) Switch to the master branch</h2>
  203. <p>If you intend to modify the go source code, and
  204. <a href="/doc/contribute.html">contribute your changes</a>
  205. to the project, then move your repository
  206. off the release branch, and onto the master (development) branch.
  207. Otherwise, skip this step.</p>
  208. <pre>
  209. $ git checkout master
  210. </pre>
  211. <h2 id="install">Install Go</h2>
  212. <p>
  213. To build the Go distribution, run
  214. </p>
  215. <pre>
  216. $ cd src
  217. $ ./all.bash
  218. </pre>
  219. <p>
  220. (To build under Windows use <code>all.bat</code>.)
  221. </p>
  222. <p>
  223. If all goes well, it will finish by printing output like:
  224. </p>
  225. <pre>
  226. ALL TESTS PASSED
  227. ---
  228. Installed Go for linux/amd64 in /home/you/go.
  229. Installed commands in /home/you/go/bin.
  230. *** You need to add /home/you/go/bin to your $PATH. ***
  231. </pre>
  232. <p>
  233. where the details on the last few lines reflect the operating system,
  234. architecture, and root directory used during the install.
  235. </p>
  236. <div class="detail">
  237. <p>
  238. For more information about ways to control the build, see the discussion of
  239. <a href="#environment">environment variables</a> below.
  240. <code>all.bash</code> (or <code>all.bat</code>) runs important tests for Go,
  241. which can take more time than simply building Go. If you do not want to run
  242. the test suite use <code>make.bash</code> (or <code>make.bat</code>)
  243. instead.
  244. </p>
  245. </div>
  246. <h2 id="testing">Testing your installation</h2>
  247. <p>
  248. Check that Go is installed correctly by building a simple program.
  249. </p>
  250. <p>
  251. Create a file named <code>hello.go</code> and put the following program in it:
  252. </p>
  253. <pre>
  254. package main
  255. import "fmt"
  256. func main() {
  257. fmt.Printf("hello, world\n")
  258. }
  259. </pre>
  260. <p>
  261. Then run it with the <code>go</code> tool:
  262. </p>
  263. <pre>
  264. $ go run hello.go
  265. hello, world
  266. </pre>
  267. <p>
  268. If you see the "hello, world" message then Go is installed correctly.
  269. </p>
  270. <h2 id="gopath">Set up your work environment</h2>
  271. <p>
  272. You're almost done.
  273. You just need to do a little more setup.
  274. </p>
  275. <p>
  276. <a href="/doc/code.html" class="download" id="start">
  277. <span class="big">How to Write Go Code</span>
  278. <span class="desc">Learn how to set up and use the Go tools</span>
  279. </a>
  280. </p>
  281. <p>
  282. The <a href="/doc/code.html">How to Write Go Code</a> document
  283. provides <b>essential setup instructions</b> for using the Go tools.
  284. </p>
  285. <h2 id="tools">Install additional tools</h2>
  286. <p>
  287. The source code for several Go tools (including <a href="/cmd/godoc/">godoc</a>)
  288. is kept in <a href="https://golang.org/x/tools">the go.tools repository</a>.
  289. To install all of them, run the <code>go</code> <code>get</code> command:
  290. </p>
  291. <pre>
  292. $ go get golang.org/x/tools/cmd/...
  293. </pre>
  294. <p>
  295. Or if you just want to install a specific command (<code>godoc</code> in this case):
  296. </p>
  297. <pre>
  298. $ go get golang.org/x/tools/cmd/godoc
  299. </pre>
  300. <p>
  301. To install these tools, the <code>go</code> <code>get</code> command requires
  302. that <a href="#git">Git</a> be installed locally.
  303. </p>
  304. <p>
  305. You must also have a workspace (<code>GOPATH</code>) set up;
  306. see <a href="/doc/code.html">How to Write Go Code</a> for the details.
  307. </p>
  308. <p>
  309. <b>Note</b>: The <code>go</code> command will install the <code>godoc</code>
  310. binary to <code>$GOROOT/bin</code> (or <code>$GOBIN</code>) and the
  311. <code>cover</code> and <code>vet</code> binaries to
  312. <code>$GOROOT/pkg/tool/$GOOS_$GOARCH</code>.
  313. You can access the latter commands with
  314. "<code>go</code> <code>tool</code> <code>cover</code>" and
  315. "<code>go</code> <code>tool</code> <code>vet</code>".
  316. </p>
  317. <h2 id="community">Community resources</h2>
  318. <p>
  319. The usual community resources such as
  320. <code>#go-nuts</code> on the <a href="http://freenode.net/">Freenode</a> IRC server
  321. and the
  322. <a href="//groups.google.com/group/golang-nuts">Go Nuts</a>
  323. mailing list have active developers that can help you with problems
  324. with your installation or your development work.
  325. For those who wish to keep up to date,
  326. there is another mailing list, <a href="//groups.google.com/group/golang-checkins">golang-checkins</a>,
  327. that receives a message summarizing each checkin to the Go repository.
  328. </p>
  329. <p>
  330. Bugs can be reported using the <a href="//golang.org/issue/new">Go issue tracker</a>.
  331. </p>
  332. <h2 id="releases">Keeping up with releases</h2>
  333. <p>
  334. New releases are announced on the
  335. <a href="//groups.google.com/group/golang-announce">golang-announce</a>
  336. mailing list.
  337. Each announcement mentions the latest release tag, for instance,
  338. <code class="versionTag">go1.8.1</code>.
  339. </p>
  340. <p>
  341. To update an existing tree to the latest release, you can run:
  342. </p>
  343. <pre>
  344. $ cd go/src
  345. $ git fetch
  346. $ git checkout <span class="versionTag"><i>&lt;tag&gt;</i></psan>
  347. $ ./all.bash
  348. </pre>
  349. <p class="whereTag">
  350. Where <code>&lt;tag&gt;</code> is the version string of the release.
  351. </p>
  352. <h2 id="environment">Optional environment variables</h2>
  353. <p>
  354. The Go compilation environment can be customized by environment variables.
  355. <i>None is required by the build</i>, but you may wish to set some
  356. to override the defaults.
  357. </p>
  358. <ul>
  359. <li><code>$GOROOT</code>
  360. <p>
  361. The root of the Go tree, often <code>$HOME/go1.X</code>.
  362. Its value is built into the tree when it is compiled, and
  363. defaults to the parent of the directory where <code>all.bash</code> was run.
  364. There is no need to set this unless you want to switch between multiple
  365. local copies of the repository.
  366. </p>
  367. <li><code>$GOROOT_FINAL</code>
  368. <p>
  369. The value assumed by installed binaries and scripts when
  370. <code>$GOROOT</code> is not set explicitly.
  371. It defaults to the value of <code>$GOROOT</code>.
  372. If you want to build the Go tree in one location
  373. but move it elsewhere after the build, set
  374. <code>$GOROOT_FINAL</code> to the eventual location.
  375. </p>
  376. <li><code>$GOOS</code> and <code>$GOARCH</code>
  377. <p>
  378. The name of the target operating system and compilation architecture.
  379. These default to the values of <code>$GOHOSTOS</code> and
  380. <code>$GOHOSTARCH</code> respectively (described below).
  381. <p>
  382. Choices for <code>$GOOS</code> are
  383. <code>darwin</code> (Mac OS X 10.8 and above and iOS), <code>dragonfly</code>, <code>freebsd</code>,
  384. <code>linux</code>, <code>netbsd</code>, <code>openbsd</code>,
  385. <code>plan9</code>, <code>solaris</code> and <code>windows</code>.
  386. Choices for <code>$GOARCH</code> are
  387. <code>amd64</code> (64-bit x86, the most mature port),
  388. <code>386</code> (32-bit x86), <code>arm</code> (32-bit ARM), <code>arm64</code> (64-bit ARM),
  389. <code>ppc64le</code> (PowerPC 64-bit, little-endian), <code>ppc64</code> (PowerPC 64-bit, big-endian),
  390. <code>mips64le</code> (MIPS 64-bit, little-endian), and <code>mips64</code> (MIPS 64-bit, big-endian).
  391. <code>mipsle</code> (MIPS 32-bit, little-endian), and <code>mips</code> (MIPS 32-bit, big-endian).
  392. The valid combinations of <code>$GOOS</code> and <code>$GOARCH</code> are:
  393. <table cellpadding="0">
  394. <tr>
  395. <th width="50"></th><th align="left" width="100"><code>$GOOS</code></th> <th align="left" width="100"><code>$GOARCH</code></th>
  396. </tr>
  397. <tr>
  398. <td></td><td><code>android</code></td> <td><code>arm</code></td>
  399. </tr>
  400. <tr>
  401. <td></td><td><code>darwin</code></td> <td><code>386</code></td>
  402. </tr>
  403. <tr>
  404. <td></td><td><code>darwin</code></td> <td><code>amd64</code></td>
  405. </tr>
  406. <tr>
  407. <td></td><td><code>darwin</code></td> <td><code>arm</code></td>
  408. </tr>
  409. <tr>
  410. <td></td><td><code>darwin</code></td> <td><code>arm64</code></td>
  411. </tr>
  412. <tr>
  413. <td></td><td><code>dragonfly</code></td> <td><code>amd64</code></td>
  414. </tr>
  415. <tr>
  416. <td></td><td><code>freebsd</code></td> <td><code>386</code></td>
  417. </tr>
  418. <tr>
  419. <td></td><td><code>freebsd</code></td> <td><code>amd64</code></td>
  420. </tr>
  421. <tr>
  422. <td></td><td><code>freebsd</code></td> <td><code>arm</code></td>
  423. </tr>
  424. <tr>
  425. <td></td><td><code>linux</code></td> <td><code>386</code></td>
  426. </tr>
  427. <tr>
  428. <td></td><td><code>linux</code></td> <td><code>amd64</code></td>
  429. </tr>
  430. <tr>
  431. <td></td><td><code>linux</code></td> <td><code>arm</code></td>
  432. </tr>
  433. <tr>
  434. <td></td><td><code>linux</code></td> <td><code>arm64</code></td>
  435. </tr>
  436. <tr>
  437. <td></td><td><code>linux</code></td> <td><code>ppc64</code></td>
  438. </tr>
  439. <tr>
  440. <td></td><td><code>linux</code></td> <td><code>ppc64le</code></td>
  441. </tr>
  442. <tr>
  443. <td></td><td><code>linux</code></td> <td><code>mips</code></td>
  444. </tr>
  445. <tr>
  446. <td></td><td><code>linux</code></td> <td><code>mipsle</code></td>
  447. </tr>
  448. <tr>
  449. <td></td><td><code>linux</code></td> <td><code>mips64</code></td>
  450. </tr>
  451. <tr>
  452. <td></td><td><code>linux</code></td> <td><code>mips64le</code></td>
  453. </tr>
  454. <tr>
  455. <td></td><td><code>netbsd</code></td> <td><code>386</code></td>
  456. </tr>
  457. <tr>
  458. <td></td><td><code>netbsd</code></td> <td><code>amd64</code></td>
  459. </tr>
  460. <tr>
  461. <td></td><td><code>netbsd</code></td> <td><code>arm</code></td>
  462. </tr>
  463. <tr>
  464. <td></td><td><code>openbsd</code></td> <td><code>386</code></td>
  465. </tr>
  466. <tr>
  467. <td></td><td><code>openbsd</code></td> <td><code>amd64</code></td>
  468. </tr>
  469. <tr>
  470. <td></td><td><code>openbsd</code></td> <td><code>arm</code></td>
  471. </tr>
  472. <tr>
  473. <td></td><td><code>plan9</code></td> <td><code>386</code></td>
  474. </tr>
  475. <tr>
  476. <td></td><td><code>plan9</code></td> <td><code>amd64</code></td>
  477. </tr>
  478. <tr>
  479. <td></td><td><code>solaris</code></td> <td><code>amd64</code></td>
  480. </tr>
  481. <tr>
  482. <td></td><td><code>windows</code></td> <td><code>386</code></td>
  483. </tr>
  484. <tr>
  485. <td></td><td><code>windows</code></td> <td><code>amd64</code></td>
  486. </tr>
  487. </table>
  488. <br>
  489. <li><code>$GOHOSTOS</code> and <code>$GOHOSTARCH</code>
  490. <p>
  491. The name of the host operating system and compilation architecture.
  492. These default to the local system's operating system and
  493. architecture.
  494. </p>
  495. <p>
  496. Valid choices are the same as for <code>$GOOS</code> and
  497. <code>$GOARCH</code>, listed above.
  498. The specified values must be compatible with the local system.
  499. For example, you should not set <code>$GOHOSTARCH</code> to
  500. <code>arm</code> on an x86 system.
  501. </p>
  502. <li><code>$GOBIN</code>
  503. <p>
  504. The location where Go binaries will be installed.
  505. The default is <code>$GOROOT/bin</code>.
  506. After installing, you will want to arrange to add this
  507. directory to your <code>$PATH</code>, so you can use the tools.
  508. If <code>$GOBIN</code> is set, the <a href="/cmd/go">go command</a>
  509. installs all commands there.
  510. </p>
  511. <li><code>$GO386</code> (for <code>386</code> only, default is auto-detected
  512. if built on either <code>386</code> or <code>amd64</code>, <code>387</code> otherwise)
  513. <p>
  514. This controls the code generated by gc to use either the 387 floating-point unit
  515. (set to <code>387</code>) or SSE2 instructions (set to <code>sse2</code>) for
  516. floating point computations.
  517. </p>
  518. <ul>
  519. <li><code>GO386=387</code>: use x87 for floating point operations; should support all x86 chips (Pentium MMX or later).
  520. <li><code>GO386=sse2</code>: use SSE2 for floating point operations; has better performance than 387, but only available on Pentium 4/Opteron/Athlon 64 or later.
  521. </ul>
  522. <li><code>$GOARM</code> (for <code>arm</code> only; default is auto-detected if building
  523. on the target processor, 6 if not)
  524. <p>
  525. This sets the ARM floating point co-processor architecture version the run-time
  526. should target. If you are compiling on the target system, its value will be auto-detected.
  527. </p>
  528. <ul>
  529. <li><code>GOARM=5</code>: use software floating point; when CPU doesn't have VFP co-processor
  530. <li><code>GOARM=6</code>: use VFPv1 only; default if cross compiling; usually ARM11 or better cores (VFPv2 or better is also supported)
  531. <li><code>GOARM=7</code>: use VFPv3; usually Cortex-A cores
  532. </ul>
  533. <p>
  534. If in doubt, leave this variable unset, and adjust it if required
  535. when you first run the Go executable.
  536. The <a href="//golang.org/wiki/GoArm">GoARM</a> page
  537. on the <a href="//golang.org/wiki">Go community wiki</a>
  538. contains further details regarding Go's ARM support.
  539. </p>
  540. </ul>
  541. <p>
  542. Note that <code>$GOARCH</code> and <code>$GOOS</code> identify the
  543. <em>target</em> environment, not the environment you are running on.
  544. In effect, you are always cross-compiling.
  545. By architecture, we mean the kind of binaries
  546. that the target environment can run:
  547. an x86-64 system running a 32-bit-only operating system
  548. must set <code>GOARCH</code> to <code>386</code>,
  549. not <code>amd64</code>.
  550. </p>
  551. <p>
  552. If you choose to override the defaults,
  553. set these variables in your shell profile (<code>$HOME/.bashrc</code>,
  554. <code>$HOME/.profile</code>, or equivalent). The settings might look
  555. something like this:
  556. </p>
  557. <pre>
  558. export GOROOT=$HOME/go1.X
  559. export GOARCH=amd64
  560. export GOOS=linux
  561. </pre>
  562. <p>
  563. although, to reiterate, none of these variables needs to be set to build,
  564. install, and develop the Go tree.
  565. </p>