Download Go Click here to visit the downloads page
Official binary
distributions are available for the FreeBSD, Linux, Mac OS X (Snow Leopard
and above), and Windows operating systems and the 32-bit (386
) and
64-bit (amd64
) x86 processor architectures.
If a binary distribution is not available for your combination of operating system and architecture, try installing from source or installing gccgo instead of gc.
The gc
compiler supports the following operating systems and
architectures. Please ensure your system meets these requirements before
proceeding. If your OS or architecture is not on the list, it's possible that
gccgo
might support your setup; see
Setting up and using gccgo for details.
Operating system | Architectures | Notes |
---|---|---|
FreeBSD 7 or later | amd64, 386, arm | Debian GNU/kFreeBSD not supported; FreeBSD/ARM needs FreeBSD 10 or later |
Linux 2.6.23 or later with glibc | amd64, 386, arm | CentOS/RHEL 5.x not supported; no binary distribution for ARM yet |
Mac OS X 10.6 or later | amd64, 386 | use the gcc† that comes with Xcode‡ |
Windows 2000 or later | amd64, 386 | use mingw gcc†; cygwin or msys is not needed |
†gcc
is required only if you plan to use
cgo.
‡You only need to install the command line tools for
Xcode. If you have already
installed Xcode 4.3+, you can install it from the Components tab of the
Downloads preferences panel.
If you are upgrading from an older version of Go you must first remove the existing version.
Download the archive
and extract it into /usr/local
, creating a Go tree in
/usr/local/go
. For example:
tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz
Choose the archive file appropriate for your installation.
For instance, if you are installing Go version 1.2.1 for 64-bit x86 on Linux,
the archive you want is called go1.2.1.linux-amd64.tar.gz
.
(Typically these commands must be run as root or through sudo
.)
Add /usr/local/go/bin
to the PATH
environment
variable. You can do this by adding this line to your /etc/profile
(for a system-wide installation) or $HOME/.profile
:
export PATH=$PATH:/usr/local/go/bin
The Go binary distributions assume they will be installed in
/usr/local/go
(or c:\Go
under Windows),
but it is possible to install the Go tools to a different location.
In this case you must set the GOROOT
environment variable
to point to the directory in which it was installed.
For example, if you installed Go to your home directory you should add the
following commands to $HOME/.profile
:
export GOROOT=$HOME/go export PATH=$PATH:$GOROOT/bin
Note: GOROOT
must be set only when installing to a custom
location.
Download the package file,
open it, and follow the prompts to install the Go tools.
The package installs the Go distribution to /usr/local/go
.
The package should put the /usr/local/go/bin
directory in your
PATH
environment variable. You may need to restart any open
Terminal sessions for the change to take effect.
The Go project provides two installation options for Windows users (besides installing from source): a zip archive that requires you to set some environment variables and an MSI installer that configures your installation automatically.
Open the MSI file
and follow the prompts to install the Go tools.
By default, the installer puts the Go distribution in c:\Go
.
The installer should put the c:\Go\bin
directory in your
PATH
environment variable. You may need to restart any open
command prompts for the change to take effect.
Download the zip file and extract it into the directory of your choice (we suggest c:\Go
).
If you chose a directory other than c:\Go
,
you must set the GOROOT
environment variable to your chosen path.
Add the bin
subdirectory of your Go root (for example, c:\Go\bin
) to your PATH
environment variable.
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.
Check that Go is installed correctly by building a simple program, as follows.
Create a file named hello.go
and put the following program in it:
package main import "fmt" func main() { fmt.Printf("hello, world\n") }
Then run it with the go
tool:
$ go run hello.go hello, world
If you see the "hello, world" message then your Go installation is working.
You're almost done. You just need to do a little more setup.
How to Write Go Code Learn how to set up and use the Go tools
The How to Write Go Code document provides essential setup instructions for using the Go tools.
To remove an existing Go installation from your system delete the
go
directory. This is usually /usr/local/go
under Linux, Mac OS X, and FreeBSD or c:\Go
under Windows.
You should also remove the Go bin
directory from your
PATH
environment variable.
Under Linux and FreeBSD you should edit /etc/profile
or
$HOME/.profile
.
If you installed Go with the Mac OS X package then you
should remove the /etc/paths.d/go
file.
Windows users should read the section about setting
environment variables under Windows.
For real-time help, ask the helpful gophers in #go-nuts
on the
Freenode IRC server.
The official mailing list for discussion of the Go language is Go Nuts.
Report bugs using the Go issue tracker.