| <!--{ | |
| "Title": "Getting Started", | |
| "Path": "/doc/install" | |
| }--> | |
| <h2 id="introduction">Introduction</h2> | |
| <p> | |
| Go is an open source project with a BSD-style license. | |
| There are two official Go compiler toolchains: the <code>gc</code> Go compiler | |
| and the <code>gccgo</code> compiler that is part of the GNU C Compiler (GCC). | |
| </p> | |
| <p> | |
| The <code>gc</code> compiler is the more mature and well-tested of the two. | |
| This page is about installing a binary distribution of the <code>gc</code> | |
| compiler. | |
| </p> | |
| <p> | |
| For information about installing the <code>gc</code> compiler from source, see | |
| <a href="/doc/install/source">Installing Go from source</a>. | |
| For information about installing <code>gccgo</code>, see | |
| <a href="/doc/install/gccgo">Setting up and using gccgo</a>. | |
| </p> | |
| <h2 id="download">Download the Go tools</h2> | |
| <p> | |
| Visit the | |
| <a href="http://code.google.com/p/go/downloads">Go project's downloads page</a> | |
| and select the binary distribution that matches | |
| your operating system and processor architecture. | |
| </p> | |
| <p> | |
| Official binary distributions are available | |
| for the FreeBSD, Linux, Mac OS X (Snow Leopard/Lion), and Windows operating systems | |
| and the 32-bit (<code>386</code>) and 64-bit (<code>amd64</code>) | |
| x86 processor architectures. | |
| </p> | |
| <p> | |
| If a binary distribution is not available for your | |
| OS/arch combination you may want to try | |
| <a href="/doc/install/source">installing from source</a> or | |
| <a href="/doc/install/gccgo">installing gccgo instead of gc</a>. | |
| </p> | |
| <h2 id="install">Install the Go tools</h2> | |
| <p> | |
| The Go binary distributions assume they will be installed in | |
| <code>/usr/local/go</code> (or <code>c:\Go</code> under Windows), | |
| but it is possible to install them in a different | |
| location. If you do this, you will need to set the <code>GOROOT</code> | |
| environment variable to that directory when using the Go tools. | |
| </p> | |
| <p> | |
| For example, if you installed Go to your home directory you should add the | |
| following commands to <code>$HOME/.profile</code>: | |
| </p> | |
| <pre> | |
| export GOROOT=$HOME/go | |
| export PATH=$PATH:$GOROOT/bin | |
| </pre> | |
| <p> | |
| Windows users should read the section about <a href="#windows_env">setting | |
| environment variables under Windows</a>. | |
| </p> | |
| <h3 id="freebsd_linux">FreeBSD and Linux</h3> | |
| <p> | |
| On FreeBSD and Linux, if you are upgrading from an older version of Go you must | |
| first remove the existing version from <code>/usr/local/go</code>: | |
| </p> | |
| <pre> | |
| rm -r /usr/local/go | |
| </pre> | |
| <p> | |
| Extract <a href="http://code.google.com/p/go/downloads/list?q=OpSys-FreeBSD+OR+OpSys-Linux">the archive</a> | |
| into <code>/usr/local</code>, creating a Go tree in <code>/usr/local/go</code>: | |
| </p> | |
| <pre> | |
| tar -C /usr/local -xzf go.release.go1.tar.gz | |
| </pre> | |
| <p> | |
| (Typically these commands must be run as root or through <code>sudo</code>.) | |
| </p> | |
| <p> | |
| Add <code>/usr/local/go/bin</code> to the <code>PATH</code> environment | |
| variable. You can do this by adding this line to your <code>/etc/profile</code> | |
| (for a system-wide installation) or <code>$HOME/.profile</code>: | |
| </p> | |
| <pre> | |
| export PATH=$PATH:/usr/local/go/bin | |
| </pre> | |
| <h3 id="osx">Mac OS X</h3> | |
| <p> | |
| Open the <a href="http://code.google.com/p/go/downloads/list?q=OpSys-Darwin">package file</a> | |
| and follow the prompts to install the Go tools. | |
| The package installs the Go distribution to <code>/usr/local/go</code>. | |
| </p> | |
| <p> | |
| The package should put the <code>/usr/local/go/bin</code> directory in your | |
| <code>PATH</code> environment variable. You may need to restart any open | |
| Terminal sessions for the change to take effect. | |
| </p> | |
| <h3 id="windows">Windows</h3> | |
| <p> | |
| The Go project provides two installation options for Windows users | |
| (besides <a href="/doc/install/source">installing from source</a>): | |
| a zip archive that requires you to set some environment variables and an | |
| experimental MSI installer that configures your installation automatically. | |
| </p> | |
| <h4 id="windows_zip">Zip archive</h3> | |
| <p> | |
| Extract the <a href="http://code.google.com/p/go/downloads/list?q=OpSys-Windows+Type%3DArchive">zip file</a> | |
| to the directory of your choice (we suggest <code>c:\Go</code>). | |
| </p> | |
| <p> | |
| If you chose a directory other than <code>c:\Go</code>, you must set | |
| the <code>GOROOT</code> environment variable to your chosen path. | |
| </p> | |
| <p> | |
| Add the <code>bin</code> subdirectory of your Go root (for example, <code>c:\Go\bin</code>) to to your <code>PATH</code> environment variable. | |
| </p> | |
| <h4 id="windows_msi">MSI installer (experimental)</h3> | |
| <p> | |
| Open the <a href="http://code.google.com/p/go/downloads/list?q=OpSys-Windows+Type%3DInstaller">MSI file</a> | |
| and follow the prompts to install the Go tools. | |
| By default, the installer puts the Go distribution in <code>c:\Go</code>. | |
| </p> | |
| <p> | |
| The installer should put the <code>c:\Go\bin</code> directory in your | |
| <code>PATH</code> environment variable. You may need to restart any open | |
| command prompts for the change to take effect. | |
| </p> | |
| <h4 id="windows_env">Setting environment variables under Windows</h4> | |
| <p> | |
| Under Windows, you may set environment variables through the "Environment | |
| Variables" button on the "Advanced" tab of the "System" control panel. Some | |
| versions of Windows provide this control panel through the "Advanced System | |
| Settings" option inside the "System" control panel. | |
| </p> | |
| <h2 id="testing">Test your installation</h2> | |
| <p> | |
| Check that Go is installed correctly by building a simple program, as follows. | |
| </p> | |
| <p> | |
| Create a file named <code>hello.go</code> and put the following program in it: | |
| </p> | |
| <pre> | |
| package main | |
| import "fmt" | |
| func main() { | |
| fmt.Printf("hello, world\n") | |
| } | |
| </pre> | |
| <p> | |
| Then run it with the <code>go</code> tool: | |
| </p> | |
| <pre> | |
| $ go run hello.go | |
| hello, world | |
| </pre> | |
| <p> | |
| If you see the "hello, world" message then your Go installation is working. | |
| </p> | |
| <h2 id="next">What's next</h2> | |
| <p> | |
| Start by taking <a href="http://code.google.com/p/go-tour/">A Tour of Go</a>. | |
| </p> | |
| <p> | |
| For more detail about the process of building and testing Go programs | |
| read <a href="/doc/code.html">How to Write Go Code</a>. | |
| </p> | |
| <p> | |
| Build a web application by following the <a href="/doc/articles/wiki/">Wiki | |
| Tutorial</a>. | |
| </p> | |
| <p> | |
| Read <a href="/doc/effective_go.html">Effective Go</a> to learn about writing | |
| idiomatic Go code. | |
| </p> | |
| <p> | |
| For the full story, consult Go's extensive <a href="/doc/">documentation</a>. | |
| </p> | |
| <p> | |
| Subscribe to the | |
| <a href="http://groups.google.com/group/golang-announce">golang-announce</a> | |
| mailing list to be notified when a new stable version of Go is released. | |
| </p> | |
| <h2 id="community">Community resources</h2> | |
| <p> | |
| For real-time help, there may be users or developers on | |
| <code>#go-nuts</code> on the <a href="http://freenode.net/">Freenode</a> IRC server. | |
| </p> | |
| <p> | |
| The official mailing list for discussion of the Go language is | |
| <a href="http://groups.google.com/group/golang-nuts">Go Nuts</a>. | |
| </p> | |
| <p> | |
| Bugs should be reported using the | |
| <a href="http://code.google.com/p/go/issues/list">Go issue tracker</a>. | |
| </p> |