Andrew Gerrand | 7cb21a7 | 2012-01-19 11:24:54 +1100 | [diff] [blame] | 1 | <!--{ |
Andrew Gerrand | d84de09 | 2012-02-13 21:22:36 +1100 | [diff] [blame] | 2 | "Title": "Getting Started", |
Andrew Gerrand | f78d50c | 2012-03-05 14:31:27 +1100 | [diff] [blame] | 3 | "Path": "/doc/install" |
Andrew Gerrand | 7cb21a7 | 2012-01-19 11:24:54 +1100 | [diff] [blame] | 4 | }--> |
Russ Cox | fb39a4d | 2009-10-23 15:24:08 -0700 | [diff] [blame] | 5 | |
Andrew Gerrand | 31b0b73 | 2015-08-05 11:58:44 +1000 | [diff] [blame] | 6 | <div class="hideFromDownload"> |
| 7 | |
Andrew Gerrand | 062a86b | 2013-04-03 15:59:17 +1100 | [diff] [blame] | 8 | <h2 id="download">Download the Go distribution</h2> |
Russ Cox | fb39a4d | 2009-10-23 15:24:08 -0700 | [diff] [blame] | 9 | |
| 10 | <p> |
Andrew Bonventre | 3810f5b | 2018-01-19 22:47:23 -0500 | [diff] [blame] | 11 | <a href="/dl/" id="start" class="download"> |
Andrew Gerrand | 062a86b | 2013-04-03 15:59:17 +1100 | [diff] [blame] | 12 | <span class="big">Download Go</span> |
| 13 | <span class="desc">Click here to visit the downloads page</span> |
| 14 | </a> |
Russ Cox | fb39a4d | 2009-10-23 15:24:08 -0700 | [diff] [blame] | 15 | </p> |
| 16 | |
Rob Pike | 5f50a81 | 2009-11-05 15:07:42 -0800 | [diff] [blame] | 17 | <p> |
Andrew Bonventre | 3810f5b | 2018-01-19 22:47:23 -0500 | [diff] [blame] | 18 | <a href="/dl/" target="_blank">Official binary |
Mikio Hara | e76ae8a | 2017-08-19 13:46:48 +0900 | [diff] [blame] | 19 | distributions</a> are available for the FreeBSD (release 10-STABLE and above), |
Brad Fitzpatrick | 219ca60 | 2016-08-06 10:12:03 -0700 | [diff] [blame] | 20 | Linux, Mac OS X (10.8 and above), and Windows operating systems and |
Bill Thiede | e9ce76b | 2015-01-17 21:09:15 -0800 | [diff] [blame] | 21 | the 32-bit (<code>386</code>) and 64-bit (<code>amd64</code>) x86 processor |
| 22 | architectures. |
Andrew Gerrand | 062a86b | 2013-04-03 15:59:17 +1100 | [diff] [blame] | 23 | </p> |
| 24 | |
| 25 | <p> |
| 26 | If a binary distribution is not available for your combination of operating |
Andrew Gerrand | c497c9e | 2013-11-21 07:55:29 +1100 | [diff] [blame] | 27 | system and architecture, try |
Andrew Gerrand | 062a86b | 2013-04-03 15:59:17 +1100 | [diff] [blame] | 28 | <a href="/doc/install/source">installing from source</a> or |
| 29 | <a href="/doc/install/gccgo">installing gccgo instead of gc</a>. |
Rob Pike | 5f50a81 | 2009-11-05 15:07:42 -0800 | [diff] [blame] | 30 | </p> |
| 31 | |
Andrew Gerrand | c497c9e | 2013-11-21 07:55:29 +1100 | [diff] [blame] | 32 | |
Shenghou Ma | ab708e3 | 2012-05-16 14:54:48 +1000 | [diff] [blame] | 33 | <h2 id="requirements">System requirements</h2> |
Andrew Gerrand | c497c9e | 2013-11-21 07:55:29 +1100 | [diff] [blame] | 34 | |
Shenghou Ma | ab708e3 | 2012-05-16 14:54:48 +1000 | [diff] [blame] | 35 | <p> |
Andrew Bonventre | 3810f5b | 2018-01-19 22:47:23 -0500 | [diff] [blame] | 36 | Go <a href="/dl/">binary distributions</a> are available for these supported operating systems and architectures. |
Russ Cox | 5457563 | 2015-08-18 11:15:15 -0400 | [diff] [blame] | 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>. |
Shenghou Ma | ab708e3 | 2012-05-16 14:54:48 +1000 | [diff] [blame] | 41 | </p> |
| 42 | |
| 43 | <table class="codetable" frame="border" summary="requirements"> |
| 44 | <tr> |
Rob Pike | 761dace | 2014-06-10 11:19:41 -0700 | [diff] [blame] | 45 | <th align="center">Operating system</th> |
| 46 | <th align="center">Architectures</th> |
| 47 | <th align="center">Notes</th> |
Shenghou Ma | ab708e3 | 2012-05-16 14:54:48 +1000 | [diff] [blame] | 48 | </tr> |
| 49 | <tr><td colspan="3"><hr></td></tr> |
Mikio Hara | e76ae8a | 2017-08-19 13:46:48 +0900 | [diff] [blame] | 50 | <tr><td>FreeBSD 10.3 or later</td> <td>amd64, 386</td> <td>Debian GNU/kFreeBSD not supported</td></tr> |
Brad Fitzpatrick | 25de52e | 2017-06-29 19:44:07 +0000 | [diff] [blame] | 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.8 or later</td> <td>amd64</td> <td>use the clang or gcc<sup>†</sup> that comes with Xcode<sup>‡</sup> for <code>cgo</code> support</td></tr> |
| 53 | <tr><td>Windows XP SP2 or later</td> <td>amd64, 386</td> <td>use MinGW gcc<sup>†</sup>. No need for cygwin or msys.</td></tr> |
Shenghou Ma | ab708e3 | 2012-05-16 14:54:48 +1000 | [diff] [blame] | 54 | </table> |
| 55 | |
| 56 | <p> |
Brad Fitzpatrick | 0ab6bb4 | 2016-09-09 01:30:49 +0000 | [diff] [blame] | 57 | <sup>†</sup>A C compiler is required only if you plan to use |
Shenghou Ma | 2701046 | 2012-08-20 21:21:09 +0800 | [diff] [blame] | 58 | <a href="/cmd/cgo">cgo</a>.<br/> |
| 59 | <sup>‡</sup>You only need to install the command line tools for |
| 60 | <a href="http://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. |
Shenghou Ma | ab708e3 | 2012-05-16 14:54:48 +1000 | [diff] [blame] | 63 | </p> |
| 64 | |
Andrew Gerrand | 31b0b73 | 2015-08-05 11:58:44 +1000 | [diff] [blame] | 65 | </div><!-- hideFromDownload --> |
| 66 | |
Andrew Gerrand | c497c9e | 2013-11-21 07:55:29 +1100 | [diff] [blame] | 67 | |
Andrew Gerrand | ce06e15 | 2012-03-26 13:59:30 +1100 | [diff] [blame] | 68 | <h2 id="install">Install the Go tools</h2> |
Russ Cox | fb39a4d | 2009-10-23 15:24:08 -0700 | [diff] [blame] | 69 | |
| 70 | <p> |
Andrew Gerrand | 218f08a | 2012-09-17 17:01:09 -0700 | [diff] [blame] | 71 | If you are upgrading from an older version of Go you must |
Andrew Gerrand | f43b6d4 | 2013-09-16 11:20:07 +1000 | [diff] [blame] | 72 | first <a href="#uninstall">remove the existing version</a>. |
Andrew Gerrand | c497c9e | 2013-11-21 07:55:29 +1100 | [diff] [blame] | 73 | </p> |
| 74 | |
Andrew Gerrand | 31b0b73 | 2015-08-05 11:58:44 +1000 | [diff] [blame] | 75 | <div id="tarballInstructions"> |
| 76 | |
Andrew Gerrand | c497c9e | 2013-11-21 07:55:29 +1100 | [diff] [blame] | 77 | <h3 id="tarball">Linux, Mac OS X, and FreeBSD tarballs</h3> |
Andrew Gerrand | e10dc82 | 2012-02-27 14:16:56 +1100 | [diff] [blame] | 78 | |
| 79 | <p> |
Andrew Bonventre | 3810f5b | 2018-01-19 22:47:23 -0500 | [diff] [blame] | 80 | <a href="/dl/">Download the archive</a> |
Andrew Gerrand | c497c9e | 2013-11-21 07:55:29 +1100 | [diff] [blame] | 81 | and extract it into <code>/usr/local</code>, creating a Go tree in |
| 82 | <code>/usr/local/go</code>. For example: |
Russ Cox | fb39a4d | 2009-10-23 15:24:08 -0700 | [diff] [blame] | 83 | </p> |
| 84 | |
| 85 | <pre> |
Andrew Gerrand | 31b0b73 | 2015-08-05 11:58:44 +1000 | [diff] [blame] | 86 | tar -C /usr/local -xzf <span class="downloadFilename">go$VERSION.$OS-$ARCH.tar.gz</span> |
Russ Cox | fb39a4d | 2009-10-23 15:24:08 -0700 | [diff] [blame] | 87 | </pre> |
| 88 | |
Andrew Gerrand | 31b0b73 | 2015-08-05 11:58:44 +1000 | [diff] [blame] | 89 | <p class="hideFromDownload"> |
Shenghou Ma | 2b6eb11 | 2014-02-06 16:09:01 -0500 | [diff] [blame] | 90 | Choose the archive file appropriate for your installation. |
Andrew Gerrand | 77edde1a | 2014-03-03 11:26:18 +1100 | [diff] [blame] | 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>. |
Andrew Gerrand | a7d4c3f | 2012-09-27 15:34:18 -0700 | [diff] [blame] | 93 | </p> |
| 94 | |
| 95 | <p> |
Andrew Gerrand | ce06e15 | 2012-03-26 13:59:30 +1100 | [diff] [blame] | 96 | (Typically these commands must be run as root or through <code>sudo</code>.) |
| 97 | </p> |
Andrew Gerrand | e10dc82 | 2012-02-27 14:16:56 +1100 | [diff] [blame] | 98 | |
Russ Cox | fb39a4d | 2009-10-23 15:24:08 -0700 | [diff] [blame] | 99 | <p> |
Andrew Gerrand | e07f089 | 2012-02-14 17:02:28 +1100 | [diff] [blame] | 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>: |
Russ Cox | fb39a4d | 2009-10-23 15:24:08 -0700 | [diff] [blame] | 103 | </p> |
| 104 | |
| 105 | <pre> |
Andrew Gerrand | e07f089 | 2012-02-14 17:02:28 +1100 | [diff] [blame] | 106 | export PATH=$PATH:/usr/local/go/bin |
Russ Cox | fb39a4d | 2009-10-23 15:24:08 -0700 | [diff] [blame] | 107 | </pre> |
| 108 | |
Oling Cat | 07d2195 | 2013-11-25 13:36:16 +1100 | [diff] [blame] | 109 | <h4 id="tarball_non_standard">Installing to a custom location</h4> |
Andrew Gerrand | c497c9e | 2013-11-21 07:55:29 +1100 | [diff] [blame] | 110 | |
| 111 | <p> |
| 112 | The Go binary distributions assume they will be installed in |
| 113 | <code>/usr/local/go</code> (or <code>c:\Go</code> under Windows), |
Oling Cat | 07d2195 | 2013-11-25 13:36:16 +1100 | [diff] [blame] | 114 | but it is possible to install the Go tools to a different location. |
Andrew Gerrand | c497c9e | 2013-11-21 07:55:29 +1100 | [diff] [blame] | 115 | In this case you must set the <code>GOROOT</code> environment variable |
| 116 | to point to the directory in which it was installed. |
| 117 | </p> |
| 118 | |
| 119 | <p> |
Russ Cox | 74628a8 | 2016-11-30 14:56:58 -0500 | [diff] [blame] | 120 | For example, if you installed Go to your home directory you should add |
| 121 | commands like the following to <code>$HOME/.profile</code>: |
Andrew Gerrand | c497c9e | 2013-11-21 07:55:29 +1100 | [diff] [blame] | 122 | </p> |
| 123 | |
| 124 | <pre> |
Russ Cox | 74628a8 | 2016-11-30 14:56:58 -0500 | [diff] [blame] | 125 | export GOROOT=$HOME/go1.X |
Andrew Gerrand | c497c9e | 2013-11-21 07:55:29 +1100 | [diff] [blame] | 126 | export PATH=$PATH:$GOROOT/bin |
| 127 | </pre> |
| 128 | |
| 129 | <p> |
| 130 | <b>Note</b>: <code>GOROOT</code> must be set only when installing to a custom |
| 131 | location. |
| 132 | </p> |
| 133 | |
Andrew Gerrand | 31b0b73 | 2015-08-05 11:58:44 +1000 | [diff] [blame] | 134 | </div><!-- tarballInstructions --> |
| 135 | |
| 136 | <div id="darwinPackageInstructions"> |
| 137 | |
Andrew Gerrand | 218f08a | 2012-09-17 17:01:09 -0700 | [diff] [blame] | 138 | <h3 id="osx">Mac OS X package installer</h3> |
Andrew Gerrand | e07f089 | 2012-02-14 17:02:28 +1100 | [diff] [blame] | 139 | |
Russ Cox | fb39a4d | 2009-10-23 15:24:08 -0700 | [diff] [blame] | 140 | <p> |
Andrew Bonventre | 3810f5b | 2018-01-19 22:47:23 -0500 | [diff] [blame] | 141 | <a href="/dl/">Download the package file</a>, |
Andrew Gerrand | c497c9e | 2013-11-21 07:55:29 +1100 | [diff] [blame] | 142 | open it, and follow the prompts to install the Go tools. |
Andrew Gerrand | e07f089 | 2012-02-14 17:02:28 +1100 | [diff] [blame] | 143 | The package installs the Go distribution to <code>/usr/local/go</code>. |
Russ Cox | fb39a4d | 2009-10-23 15:24:08 -0700 | [diff] [blame] | 144 | </p> |
| 145 | |
Andrew Gerrand | e07f089 | 2012-02-14 17:02:28 +1100 | [diff] [blame] | 146 | <p> |
| 147 | The package should put the <code>/usr/local/go/bin</code> directory in your |
| 148 | <code>PATH</code> environment variable. You may need to restart any open |
| 149 | Terminal sessions for the change to take effect. |
| 150 | </p> |
Andrew Gerrand | 6ab8d24 | 2010-09-16 14:01:02 +1000 | [diff] [blame] | 151 | |
Andrew Gerrand | 31b0b73 | 2015-08-05 11:58:44 +1000 | [diff] [blame] | 152 | </div><!-- darwinPackageInstructions --> |
| 153 | |
| 154 | <div id="windowsInstructions"> |
| 155 | |
Andrew Gerrand | e07f089 | 2012-02-14 17:02:28 +1100 | [diff] [blame] | 156 | <h3 id="windows">Windows</h3> |
Russ Cox | fb39a4d | 2009-10-23 15:24:08 -0700 | [diff] [blame] | 157 | |
Andrew Gerrand | 31b0b73 | 2015-08-05 11:58:44 +1000 | [diff] [blame] | 158 | <p class="hideFromDownload"> |
Andrew Gerrand | cf46040 | 2012-03-13 15:02:14 +1100 | [diff] [blame] | 159 | The Go project provides two installation options for Windows users |
| 160 | (besides <a href="/doc/install/source">installing from source</a>): |
Andrew Gerrand | 1b89d51 | 2012-03-27 11:19:30 +1100 | [diff] [blame] | 161 | a zip archive that requires you to set some environment variables and an |
Andrew Gerrand | f43b6d4 | 2013-09-16 11:20:07 +1000 | [diff] [blame] | 162 | MSI installer that configures your installation automatically. |
Andrew Gerrand | cf46040 | 2012-03-13 15:02:14 +1100 | [diff] [blame] | 163 | </p> |
| 164 | |
Andrew Gerrand | 31b0b73 | 2015-08-05 11:58:44 +1000 | [diff] [blame] | 165 | <div id="windowsInstallerInstructions"> |
| 166 | |
Andrew Gerrand | f43b6d4 | 2013-09-16 11:20:07 +1000 | [diff] [blame] | 167 | <h4 id="windows_msi">MSI installer</h4> |
Andrew Gerrand | cf46040 | 2012-03-13 15:02:14 +1100 | [diff] [blame] | 168 | |
| 169 | <p> |
Andrew Bonventre | 3810f5b | 2018-01-19 22:47:23 -0500 | [diff] [blame] | 170 | Open the <a href="/dl/">MSI file</a> |
Andrew Gerrand | ce06e15 | 2012-03-26 13:59:30 +1100 | [diff] [blame] | 171 | and follow the prompts to install the Go tools. |
Andrew Gerrand | d70627e | 2012-03-06 15:16:02 +1100 | [diff] [blame] | 172 | By default, the installer puts the Go distribution in <code>c:\Go</code>. |
| 173 | </p> |
| 174 | |
| 175 | <p> |
| 176 | The installer should put the <code>c:\Go\bin</code> directory in your |
| 177 | <code>PATH</code> environment variable. You may need to restart any open |
| 178 | command prompts for the change to take effect. |
Andrew Gerrand | e07f089 | 2012-02-14 17:02:28 +1100 | [diff] [blame] | 179 | </p> |
| 180 | |
Andrew Gerrand | 31b0b73 | 2015-08-05 11:58:44 +1000 | [diff] [blame] | 181 | </div><!-- windowsInstallerInstructions --> |
| 182 | |
| 183 | <div id="windowsZipInstructions"> |
| 184 | |
Andrew Gerrand | c497c9e | 2013-11-21 07:55:29 +1100 | [diff] [blame] | 185 | <h4 id="windows_zip">Zip archive</h4> |
| 186 | |
| 187 | <p> |
Andrew Bonventre | 3810f5b | 2018-01-19 22:47:23 -0500 | [diff] [blame] | 188 | <a href="/dl/">Download the zip file</a> and extract it into the directory of your choice (we suggest <code>c:\Go</code>). |
Andrew Gerrand | c497c9e | 2013-11-21 07:55:29 +1100 | [diff] [blame] | 189 | </p> |
| 190 | |
| 191 | <p> |
| 192 | If you chose a directory other than <code>c:\Go</code>, |
| 193 | you must set the <code>GOROOT</code> environment variable to your chosen path. |
| 194 | </p> |
| 195 | |
| 196 | <p> |
| 197 | Add the <code>bin</code> subdirectory of your Go root (for example, <code>c:\Go\bin</code>) to your <code>PATH</code> environment variable. |
| 198 | </p> |
| 199 | |
Andrew Gerrand | 31b0b73 | 2015-08-05 11:58:44 +1000 | [diff] [blame] | 200 | </div><!-- windowsZipInstructions --> |
| 201 | |
Andrew Gerrand | cf46040 | 2012-03-13 15:02:14 +1100 | [diff] [blame] | 202 | <h4 id="windows_env">Setting environment variables under Windows</h4> |
| 203 | |
| 204 | <p> |
| 205 | Under Windows, you may set environment variables through the "Environment |
| 206 | Variables" button on the "Advanced" tab of the "System" control panel. Some |
| 207 | versions of Windows provide this control panel through the "Advanced System |
| 208 | Settings" option inside the "System" control panel. |
| 209 | </p> |
| 210 | |
Andrew Gerrand | 31b0b73 | 2015-08-05 11:58:44 +1000 | [diff] [blame] | 211 | </div><!-- windowsInstructions --> |
| 212 | |
Andrew Gerrand | c497c9e | 2013-11-21 07:55:29 +1100 | [diff] [blame] | 213 | |
Andrew Gerrand | ce06e15 | 2012-03-26 13:59:30 +1100 | [diff] [blame] | 214 | <h2 id="testing">Test your installation</h2> |
Andrew Gerrand | e07f089 | 2012-02-14 17:02:28 +1100 | [diff] [blame] | 215 | |
| 216 | <p> |
Andrew Gerrand | 31b0b73 | 2015-08-05 11:58:44 +1000 | [diff] [blame] | 217 | Check that Go is installed correctly by setting up a workspace |
| 218 | and building a simple program, as follows. |
Andrew Gerrand | e07f089 | 2012-02-14 17:02:28 +1100 | [diff] [blame] | 219 | </p> |
| 220 | |
| 221 | <p> |
Russ Cox | 74628a8 | 2016-11-30 14:56:58 -0500 | [diff] [blame] | 222 | Create your <a href="code.html#Workspaces">workspace</a> directory, |
| 223 | <code class="testUnix">$HOME/go</code><code class="testWindows">%USERPROFILE%\go</code>. |
| 224 | (If you'd like to use a different directory, |
Jaana Burcu Dogan | ecbf908 | 2017-02-02 11:39:02 -0800 | [diff] [blame] | 225 | you will need to <a href="https://golang.org/wiki/SettingGOPATH">set the <code>GOPATH</code> environment variable</a>.) |
Andrew Gerrand | 31b0b73 | 2015-08-05 11:58:44 +1000 | [diff] [blame] | 226 | </p> |
| 227 | |
| 228 | <p> |
Russ Cox | 74628a8 | 2016-11-30 14:56:58 -0500 | [diff] [blame] | 229 | Next, make the directory <code>src/hello</code> inside your workspace, |
| 230 | and in that directory create a file named <code>hello.go</code> that looks like: |
Russ Cox | fb39a4d | 2009-10-23 15:24:08 -0700 | [diff] [blame] | 231 | </p> |
| 232 | |
| 233 | <pre> |
Russ Cox | fb39a4d | 2009-10-23 15:24:08 -0700 | [diff] [blame] | 234 | package main |
| 235 | |
| 236 | import "fmt" |
| 237 | |
| 238 | func main() { |
Andrew Gerrand | e07f089 | 2012-02-14 17:02:28 +1100 | [diff] [blame] | 239 | fmt.Printf("hello, world\n") |
Russ Cox | fb39a4d | 2009-10-23 15:24:08 -0700 | [diff] [blame] | 240 | } |
Russ Cox | fb39a4d | 2009-10-23 15:24:08 -0700 | [diff] [blame] | 241 | </pre> |
| 242 | |
| 243 | <p> |
Russ Cox | 74628a8 | 2016-11-30 14:56:58 -0500 | [diff] [blame] | 244 | Then build it with the <code>go</code> tool: |
Russ Cox | fb39a4d | 2009-10-23 15:24:08 -0700 | [diff] [blame] | 245 | </p> |
| 246 | |
Andrew Gerrand | e9fc522 | 2016-01-07 10:53:07 +1100 | [diff] [blame] | 247 | <pre class="testUnix"> |
Brad Fitzpatrick | d51046b | 2016-12-21 20:48:09 +0000 | [diff] [blame] | 248 | $ <b>cd $HOME/go/src/hello</b> |
Russ Cox | 74628a8 | 2016-11-30 14:56:58 -0500 | [diff] [blame] | 249 | $ <b>go build</b> |
Andrew Gerrand | 31b0b73 | 2015-08-05 11:58:44 +1000 | [diff] [blame] | 250 | </pre> |
| 251 | |
Jaana Burcu Dogan | b842c9a | 2017-01-10 11:25:14 -0800 | [diff] [blame] | 252 | <pre class="testWindows"> |
Brad Fitzpatrick | d51046b | 2016-12-21 20:48:09 +0000 | [diff] [blame] | 253 | C:\> <b>cd %USERPROFILE%\go\src\hello</b> |
Russ Cox | 74628a8 | 2016-11-30 14:56:58 -0500 | [diff] [blame] | 254 | C:\Users\Gopher\go\src\hello> <b>go build</b> |
Andrew Gerrand | e9fc522 | 2016-01-07 10:53:07 +1100 | [diff] [blame] | 255 | </pre> |
| 256 | |
Andrew Gerrand | 31b0b73 | 2015-08-05 11:58:44 +1000 | [diff] [blame] | 257 | <p> |
Russ Cox | 74628a8 | 2016-11-30 14:56:58 -0500 | [diff] [blame] | 258 | The command above will build an executable named |
| 259 | <code class="testUnix">hello</code><code class="testWindows">hello.exe</code> |
| 260 | in the directory alongside your source code. |
| 261 | Execute it to see the greeting: |
Andrew Gerrand | 31b0b73 | 2015-08-05 11:58:44 +1000 | [diff] [blame] | 262 | </p> |
| 263 | |
Andrew Gerrand | e9fc522 | 2016-01-07 10:53:07 +1100 | [diff] [blame] | 264 | <pre class="testUnix"> |
Russ Cox | 74628a8 | 2016-11-30 14:56:58 -0500 | [diff] [blame] | 265 | $ <b>./hello</b> |
Andrew Gerrand | e07f089 | 2012-02-14 17:02:28 +1100 | [diff] [blame] | 266 | hello, world |
| 267 | </pre> |
| 268 | |
Jaana Burcu Dogan | b842c9a | 2017-01-10 11:25:14 -0800 | [diff] [blame] | 269 | <pre class="testWindows"> |
Russ Cox | 74628a8 | 2016-11-30 14:56:58 -0500 | [diff] [blame] | 270 | C:\Users\Gopher\go\src\hello> <b>hello</b> |
Andrew Gerrand | e9fc522 | 2016-01-07 10:53:07 +1100 | [diff] [blame] | 271 | hello, world |
| 272 | </pre> |
| 273 | |
Russ Cox | fb39a4d | 2009-10-23 15:24:08 -0700 | [diff] [blame] | 274 | <p> |
Andrew Gerrand | e07f089 | 2012-02-14 17:02:28 +1100 | [diff] [blame] | 275 | If you see the "hello, world" message then your Go installation is working. |
Russ Cox | fb39a4d | 2009-10-23 15:24:08 -0700 | [diff] [blame] | 276 | </p> |
Andrew Gerrand | 6ab8d24 | 2010-09-16 14:01:02 +1000 | [diff] [blame] | 277 | |
Andrew Gerrand | 9115a8b | 2012-06-13 10:33:02 +1000 | [diff] [blame] | 278 | <p> |
Russ Cox | 74628a8 | 2016-11-30 14:56:58 -0500 | [diff] [blame] | 279 | You can run <code>go</code> <code>install</code> to install the binary into |
| 280 | your workspace's <code>bin</code> directory |
| 281 | or <code>go</code> <code>clean</code> to remove it. |
| 282 | </p> |
| 283 | |
| 284 | <p> |
Andrew Gerrand | 31b0b73 | 2015-08-05 11:58:44 +1000 | [diff] [blame] | 285 | Before rushing off to write Go code please read the |
| 286 | <a href="/doc/code.html">How to Write Go Code</a> document, |
| 287 | which describes some essential concepts about using the Go tools. |
Russ Cox | 8b04cef | 2009-11-08 23:38:30 -0800 | [diff] [blame] | 288 | </p> |
Andrew Gerrand | f43b6d4 | 2013-09-16 11:20:07 +1000 | [diff] [blame] | 289 | |
| 290 | |
| 291 | <h2 id="uninstall">Uninstalling Go</h2> |
| 292 | |
| 293 | <p> |
| 294 | To remove an existing Go installation from your system delete the |
| 295 | <code>go</code> directory. This is usually <code>/usr/local/go</code> |
| 296 | under Linux, Mac OS X, and FreeBSD or <code>c:\Go</code> |
| 297 | under Windows. |
| 298 | </p> |
| 299 | |
| 300 | <p> |
| 301 | You should also remove the Go <code>bin</code> directory from your |
| 302 | <code>PATH</code> environment variable. |
| 303 | Under Linux and FreeBSD you should edit <code>/etc/profile</code> or |
| 304 | <code>$HOME/.profile</code>. |
| 305 | If you installed Go with the <a href="#osx">Mac OS X package</a> then you |
| 306 | should remove the <code>/etc/paths.d/go</code> file. |
| 307 | Windows users should read the section about <a href="#windows_env">setting |
| 308 | environment variables under Windows</a>. |
| 309 | </p> |
| 310 | |
| 311 | |
Andrew Gerrand | c497c9e | 2013-11-21 07:55:29 +1100 | [diff] [blame] | 312 | <h2 id="help">Getting help</h2> |
| 313 | |
| 314 | <p> |
Brad Fitzpatrick | d51046b | 2016-12-21 20:48:09 +0000 | [diff] [blame] | 315 | For help, see the <a href="/help/">list of Go mailing lists, forums, and places to chat</a>. |
Andrew Gerrand | c497c9e | 2013-11-21 07:55:29 +1100 | [diff] [blame] | 316 | </p> |
| 317 | |
| 318 | <p> |
Brad Fitzpatrick | d51046b | 2016-12-21 20:48:09 +0000 | [diff] [blame] | 319 | Report bugs either by running “<b><code>go</code> <code>bug</code></b>”, or |
| 320 | manually at the <a href="https://golang.org/issue">Go issue tracker</a>. |
Andrew Gerrand | c497c9e | 2013-11-21 07:55:29 +1100 | [diff] [blame] | 321 | </p> |