install-source.html 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  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 toolchains.
  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. macOS (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 toolchain 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 toolchain.
  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 toolchain.
  120. </p>
  121. <p>
  122. To use a binary release as a bootstrap toolchain, 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 toolchain from source, use
  128. either the git branch <code>release-branch.go1.4</code> or
  129. <a href="https://dl.google.com/go/go1.4-bootstrap-20171003.tar.gz">go1.4-bootstrap-20171003.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 toolchain was written in C.)
  133. After unpacking the Go 1.4 source, <code>cd</code> to
  134. the <code>src</code> subdirectory, set <code>CGO_ENABLED=0</code> in
  135. the environment, and run <code>make.bash</code> (or,
  136. on Windows, <code>make.bat</code>).
  137. </p>
  138. <p>
  139. To cross-compile a bootstrap toolchain from source, which is
  140. necessary on systems Go 1.4 did not target (for
  141. example, <code>linux/ppc64le</code>), install Go on a different system
  142. and run <a href="/src/bootstrap.bash">bootstrap.bash</a>.
  143. </p>
  144. <p>
  145. When run as (for example)
  146. </p>
  147. <pre>
  148. $ GOOS=linux GOARCH=ppc64 ./bootstrap.bash
  149. </pre>
  150. <p>
  151. <code>bootstrap.bash</code> cross-compiles a toolchain for that <code>GOOS/GOARCH</code>
  152. combination, leaving the resulting tree in <code>../../go-${GOOS}-${GOARCH}-bootstrap</code>.
  153. That tree can be copied to a machine of the given target type
  154. and used as <code>GOROOT_BOOTSTRAP</code> to bootstrap a local build.
  155. </p>
  156. <p>
  157. To use gccgo as the bootstrap toolchain, you need to arrange
  158. for <code>$GOROOT_BOOTSTRAP/bin/go</code> to be the go tool that comes
  159. as part of gccgo 5. For example on Ubuntu Vivid:
  160. </p>
  161. <pre>
  162. $ sudo apt-get install gccgo-5
  163. $ sudo update-alternatives --set go /usr/bin/go-5
  164. $ GOROOT_BOOTSTRAP=/usr ./make.bash
  165. </pre>
  166. <h2 id="git">Install Git, if needed</h2>
  167. <p>
  168. To perform the next step you must have Git installed. (Check that you
  169. have a <code>git</code> command before proceeding.)
  170. </p>
  171. <p>
  172. If you do not have a working Git installation,
  173. follow the instructions on the
  174. <a href="https://git-scm.com/downloads">Git downloads</a> page.
  175. </p>
  176. <h2 id="ccompiler">(Optional) Install a C compiler</h2>
  177. <p>
  178. To build a Go installation
  179. with <code><a href="/cmd/cgo">cgo</a></code> support, which permits Go
  180. programs to import C libraries, a C compiler such as <code>gcc</code>
  181. or <code>clang</code> must be installed first. Do this using whatever
  182. installation method is standard on the system.
  183. </p>
  184. <p>
  185. To build without <code>cgo</code>, set the environment variable
  186. <code>CGO_ENABLED=0</code> before running <code>all.bash</code> or
  187. <code>make.bash</code>.
  188. </p>
  189. <h2 id="fetch">Fetch the repository</h2>
  190. <p>Go will install to a directory named <code>go</code>.
  191. Change to the directory that will be its parent
  192. and make sure the <code>go</code> directory does not exist.
  193. Then clone the repository and check out the latest release tag
  194. (<code class="versionTag">go1.9</code>, for example):</p>
  195. <pre>
  196. $ git clone https://go.googlesource.com/go
  197. $ cd go
  198. $ git checkout <span class="versionTag"><i>&lt;tag&gt;</i></span>
  199. </pre>
  200. <p class="whereTag">
  201. Where <code>&lt;tag&gt;</code> is the version string of the release.
  202. </p>
  203. <h2 id="head">(Optional) Switch to the master branch</h2>
  204. <p>If you intend to modify the go source code, and
  205. <a href="/doc/contribute.html">contribute your changes</a>
  206. to the project, then move your repository
  207. off the release branch, and onto the master (development) branch.
  208. Otherwise, skip this step.</p>
  209. <pre>
  210. $ git checkout master
  211. </pre>
  212. <h2 id="install">Install Go</h2>
  213. <p>
  214. To build the Go distribution, run
  215. </p>
  216. <pre>
  217. $ cd src
  218. $ ./all.bash
  219. </pre>
  220. <p>
  221. (To build under Windows use <code>all.bat</code>.)
  222. </p>
  223. <p>
  224. If all goes well, it will finish by printing output like:
  225. </p>
  226. <pre>
  227. ALL TESTS PASSED
  228. ---
  229. Installed Go for linux/amd64 in /home/you/go.
  230. Installed commands in /home/you/go/bin.
  231. *** You need to add /home/you/go/bin to your $PATH. ***
  232. </pre>
  233. <p>
  234. where the details on the last few lines reflect the operating system,
  235. architecture, and root directory used during the install.
  236. </p>
  237. <div class="detail">
  238. <p>
  239. For more information about ways to control the build, see the discussion of
  240. <a href="#environment">environment variables</a> below.
  241. <code>all.bash</code> (or <code>all.bat</code>) runs important tests for Go,
  242. which can take more time than simply building Go. If you do not want to run
  243. the test suite use <code>make.bash</code> (or <code>make.bat</code>)
  244. instead.
  245. </p>
  246. </div>
  247. <h2 id="testing">Testing your installation</h2>
  248. <p>
  249. Check that Go is installed correctly by building a simple program.
  250. </p>
  251. <p>
  252. Create a file named <code>hello.go</code> and put the following program in it:
  253. </p>
  254. <pre>
  255. package main
  256. import "fmt"
  257. func main() {
  258. fmt.Printf("hello, world\n")
  259. }
  260. </pre>
  261. <p>
  262. Then run it with the <code>go</code> tool:
  263. </p>
  264. <pre>
  265. $ go run hello.go
  266. hello, world
  267. </pre>
  268. <p>
  269. If you see the "hello, world" message then Go is installed correctly.
  270. </p>
  271. <h2 id="gopath">Set up your work environment</h2>
  272. <p>
  273. You're almost done.
  274. You just need to do a little more setup.
  275. </p>
  276. <p>
  277. <a href="/doc/code.html" class="download" id="start">
  278. <span class="big">How to Write Go Code</span>
  279. <span class="desc">Learn how to set up and use the Go tools</span>
  280. </a>
  281. </p>
  282. <p>
  283. The <a href="/doc/code.html">How to Write Go Code</a> document
  284. provides <b>essential setup instructions</b> for using the Go tools.
  285. </p>
  286. <h2 id="tools">Install additional tools</h2>
  287. <p>
  288. The source code for several Go tools (including <a href="/cmd/godoc/">godoc</a>)
  289. is kept in <a href="https://golang.org/x/tools">the go.tools repository</a>.
  290. To install one of the tools (<code>godoc</code> in this case):
  291. </p>
  292. <pre>
  293. $ go get golang.org/x/tools/cmd/godoc
  294. </pre>
  295. <p>
  296. To install these tools, the <code>go</code> <code>get</code> command requires
  297. that <a href="#git">Git</a> be installed locally.
  298. </p>
  299. <p>
  300. You must also have a workspace (<code>GOPATH</code>) set up;
  301. see <a href="/doc/code.html">How to Write Go Code</a> for the details.
  302. </p>
  303. <h2 id="community">Community resources</h2>
  304. <p>
  305. The usual community resources such as
  306. <code>#go-nuts</code> on the <a href="https://freenode.net/">Freenode</a> IRC server
  307. and the
  308. <a href="//groups.google.com/group/golang-nuts">Go Nuts</a>
  309. mailing list have active developers that can help you with problems
  310. with your installation or your development work.
  311. For those who wish to keep up to date,
  312. there is another mailing list, <a href="//groups.google.com/group/golang-checkins">golang-checkins</a>,
  313. that receives a message summarizing each checkin to the Go repository.
  314. </p>
  315. <p>
  316. Bugs can be reported using the <a href="//golang.org/issue/new">Go issue tracker</a>.
  317. </p>
  318. <h2 id="releases">Keeping up with releases</h2>
  319. <p>
  320. New releases are announced on the
  321. <a href="//groups.google.com/group/golang-announce">golang-announce</a>
  322. mailing list.
  323. Each announcement mentions the latest release tag, for instance,
  324. <code class="versionTag">go1.9</code>.
  325. </p>
  326. <p>
  327. To update an existing tree to the latest release, you can run:
  328. </p>
  329. <pre>
  330. $ cd go/src
  331. $ git fetch
  332. $ git checkout <span class="versionTag"><i>&lt;tag&gt;</i></psan>
  333. $ ./all.bash
  334. </pre>
  335. <p class="whereTag">
  336. Where <code>&lt;tag&gt;</code> is the version string of the release.
  337. </p>
  338. <h2 id="environment">Optional environment variables</h2>
  339. <p>
  340. The Go compilation environment can be customized by environment variables.
  341. <i>None is required by the build</i>, but you may wish to set some
  342. to override the defaults.
  343. </p>
  344. <ul>
  345. <li><code>$GOROOT</code>
  346. <p>
  347. The root of the Go tree, often <code>$HOME/go1.X</code>.
  348. Its value is built into the tree when it is compiled, and
  349. defaults to the parent of the directory where <code>all.bash</code> was run.
  350. There is no need to set this unless you want to switch between multiple
  351. local copies of the repository.
  352. </p>
  353. </li>
  354. <li><code>$GOROOT_FINAL</code>
  355. <p>
  356. The value assumed by installed binaries and scripts when
  357. <code>$GOROOT</code> is not set explicitly.
  358. It defaults to the value of <code>$GOROOT</code>.
  359. If you want to build the Go tree in one location
  360. but move it elsewhere after the build, set
  361. <code>$GOROOT_FINAL</code> to the eventual location.
  362. </p>
  363. </li>
  364. <li><code>$GOOS</code> and <code>$GOARCH</code>
  365. <p>
  366. The name of the target operating system and compilation architecture.
  367. These default to the values of <code>$GOHOSTOS</code> and
  368. <code>$GOHOSTARCH</code> respectively (described below).
  369. </li>
  370. <p>
  371. Choices for <code>$GOOS</code> are
  372. <code>darwin</code> (macOS 10.10 and above and iOS), <code>dragonfly</code>, <code>freebsd</code>,
  373. <code>linux</code>, <code>netbsd</code>, <code>openbsd</code>,
  374. <code>plan9</code>, <code>solaris</code> and <code>windows</code>.
  375. Choices for <code>$GOARCH</code> are
  376. <code>amd64</code> (64-bit x86, the most mature port),
  377. <code>386</code> (32-bit x86), <code>arm</code> (32-bit ARM), <code>arm64</code> (64-bit ARM),
  378. <code>ppc64le</code> (PowerPC 64-bit, little-endian), <code>ppc64</code> (PowerPC 64-bit, big-endian),
  379. <code>mips64le</code> (MIPS 64-bit, little-endian), <code>mips64</code> (MIPS 64-bit, big-endian),
  380. <code>mipsle</code> (MIPS 32-bit, little-endian), <code>mips</code> (MIPS 32-bit, big-endian), and
  381. <code>s390x</code> (IBM System z 64-bit, big-endian).
  382. The valid combinations of <code>$GOOS</code> and <code>$GOARCH</code> are:
  383. <table cellpadding="0">
  384. <tr>
  385. <th width="50"></th><th align="left" width="100"><code>$GOOS</code></th> <th align="left" width="100"><code>$GOARCH</code></th>
  386. </tr>
  387. <tr>
  388. <td></td><td><code>android</code></td> <td><code>arm</code></td>
  389. </tr>
  390. <tr>
  391. <td></td><td><code>darwin</code></td> <td><code>386</code></td>
  392. </tr>
  393. <tr>
  394. <td></td><td><code>darwin</code></td> <td><code>amd64</code></td>
  395. </tr>
  396. <tr>
  397. <td></td><td><code>darwin</code></td> <td><code>arm</code></td>
  398. </tr>
  399. <tr>
  400. <td></td><td><code>darwin</code></td> <td><code>arm64</code></td>
  401. </tr>
  402. <tr>
  403. <td></td><td><code>dragonfly</code></td> <td><code>amd64</code></td>
  404. </tr>
  405. <tr>
  406. <td></td><td><code>freebsd</code></td> <td><code>386</code></td>
  407. </tr>
  408. <tr>
  409. <td></td><td><code>freebsd</code></td> <td><code>amd64</code></td>
  410. </tr>
  411. <tr>
  412. <td></td><td><code>freebsd</code></td> <td><code>arm</code></td>
  413. </tr>
  414. <tr>
  415. <td></td><td><code>linux</code></td> <td><code>386</code></td>
  416. </tr>
  417. <tr>
  418. <td></td><td><code>linux</code></td> <td><code>amd64</code></td>
  419. </tr>
  420. <tr>
  421. <td></td><td><code>linux</code></td> <td><code>arm</code></td>
  422. </tr>
  423. <tr>
  424. <td></td><td><code>linux</code></td> <td><code>arm64</code></td>
  425. </tr>
  426. <tr>
  427. <td></td><td><code>linux</code></td> <td><code>ppc64</code></td>
  428. </tr>
  429. <tr>
  430. <td></td><td><code>linux</code></td> <td><code>ppc64le</code></td>
  431. </tr>
  432. <tr>
  433. <td></td><td><code>linux</code></td> <td><code>mips</code></td>
  434. </tr>
  435. <tr>
  436. <td></td><td><code>linux</code></td> <td><code>mipsle</code></td>
  437. </tr>
  438. <tr>
  439. <td></td><td><code>linux</code></td> <td><code>mips64</code></td>
  440. </tr>
  441. <tr>
  442. <td></td><td><code>linux</code></td> <td><code>mips64le</code></td>
  443. </tr>
  444. <tr>
  445. <td></td><td><code>linux</code></td> <td><code>s390x</code></td>
  446. </tr>
  447. <tr>
  448. <td></td><td><code>netbsd</code></td> <td><code>386</code></td>
  449. </tr>
  450. <tr>
  451. <td></td><td><code>netbsd</code></td> <td><code>amd64</code></td>
  452. </tr>
  453. <tr>
  454. <td></td><td><code>netbsd</code></td> <td><code>arm</code></td>
  455. </tr>
  456. <tr>
  457. <td></td><td><code>openbsd</code></td> <td><code>386</code></td>
  458. </tr>
  459. <tr>
  460. <td></td><td><code>openbsd</code></td> <td><code>amd64</code></td>
  461. </tr>
  462. <tr>
  463. <td></td><td><code>openbsd</code></td> <td><code>arm</code></td>
  464. </tr>
  465. <tr>
  466. <td></td><td><code>plan9</code></td> <td><code>386</code></td>
  467. </tr>
  468. <tr>
  469. <td></td><td><code>plan9</code></td> <td><code>amd64</code></td>
  470. </tr>
  471. <tr>
  472. <td></td><td><code>solaris</code></td> <td><code>amd64</code></td>
  473. </tr>
  474. <tr>
  475. <td></td><td><code>windows</code></td> <td><code>386</code></td>
  476. </tr>
  477. <tr>
  478. <td></td><td><code>windows</code></td> <td><code>amd64</code></td>
  479. </tr>
  480. </table>
  481. <br>
  482. <li><code>$GOHOSTOS</code> and <code>$GOHOSTARCH</code>
  483. <p>
  484. The name of the host operating system and compilation architecture.
  485. These default to the local system's operating system and
  486. architecture.
  487. </p>
  488. </li>
  489. <p>
  490. Valid choices are the same as for <code>$GOOS</code> and
  491. <code>$GOARCH</code>, listed above.
  492. The specified values must be compatible with the local system.
  493. For example, you should not set <code>$GOHOSTARCH</code> to
  494. <code>arm</code> on an x86 system.
  495. </p>
  496. <li><code>$GOBIN</code>
  497. <p>
  498. The location where Go binaries will be installed.
  499. The default is <code>$GOROOT/bin</code>.
  500. After installing, you will want to arrange to add this
  501. directory to your <code>$PATH</code>, so you can use the tools.
  502. If <code>$GOBIN</code> is set, the <a href="/cmd/go">go command</a>
  503. installs all commands there.
  504. </p>
  505. </li>
  506. <li><code>$GO386</code> (for <code>386</code> only, default is auto-detected
  507. if built on either <code>386</code> or <code>amd64</code>, <code>387</code> otherwise)
  508. <p>
  509. This controls the code generated by gc to use either the 387 floating-point unit
  510. (set to <code>387</code>) or SSE2 instructions (set to <code>sse2</code>) for
  511. floating point computations.
  512. </p>
  513. <ul>
  514. <li><code>GO386=387</code>: use x87 for floating point operations; should support all x86 chips (Pentium MMX or later).</li>
  515. <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.</li>
  516. </ul>
  517. </li>
  518. <li><code>$GOARM</code> (for <code>arm</code> only; default is auto-detected if building
  519. on the target processor, 6 if not)
  520. <p>
  521. This sets the ARM floating point co-processor architecture version the run-time
  522. should target. If you are compiling on the target system, its value will be auto-detected.
  523. </p>
  524. <ul>
  525. <li><code>GOARM=5</code>: use software floating point; when CPU doesn't have VFP co-processor</li>
  526. <li><code>GOARM=6</code>: use VFPv1 only; default if cross compiling; usually ARM11 or better cores (VFPv2 or better is also supported)</li>
  527. <li><code>GOARM=7</code>: use VFPv3; usually Cortex-A cores</li>
  528. </ul>
  529. <p>
  530. If in doubt, leave this variable unset, and adjust it if required
  531. when you first run the Go executable.
  532. The <a href="//golang.org/wiki/GoArm">GoARM</a> page
  533. on the <a href="//golang.org/wiki">Go community wiki</a>
  534. contains further details regarding Go's ARM support.
  535. </p>
  536. </li>
  537. <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)
  538. <p>
  539. 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.
  540. </p>
  541. </li>
  542. </ul>
  543. <p>
  544. Note that <code>$GOARCH</code> and <code>$GOOS</code> identify the
  545. <em>target</em> environment, not the environment you are running on.
  546. In effect, you are always cross-compiling.
  547. By architecture, we mean the kind of binaries
  548. that the target environment can run:
  549. an x86-64 system running a 32-bit-only operating system
  550. must set <code>GOARCH</code> to <code>386</code>,
  551. not <code>amd64</code>.
  552. </p>
  553. <p>
  554. If you choose to override the defaults,
  555. set these variables in your shell profile (<code>$HOME/.bashrc</code>,
  556. <code>$HOME/.profile</code>, or equivalent). The settings might look
  557. something like this:
  558. </p>
  559. <pre>
  560. export GOARCH=amd64
  561. export GOOS=linux
  562. </pre>
  563. <p>
  564. although, to reiterate, none of these variables needs to be set to build,
  565. install, and develop the Go tree.
  566. </p>