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