Introduction

Go is an open source project with a BSD-style license. There are two official Go compiler toolchains: the gc Go compiler and the gccgo compiler that is part of the GNU C Compiler (GCC).

The gc compiler is the more mature and well-tested of the two. This page is about installing a binary distribution of the gc compiler.

For information about installing the gc compiler from source, see Installing Go from source. For information about installing gccgo, see Setting up and using gccgo.

System requirements

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 Debian GNU/kFreeBSD not supported
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/10.7 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.

Download the Go tools

Visit the Go project's downloads page and select the binary distribution that matches your operating system and processor architecture.

Official binary distributions are available for the FreeBSD, Linux, Mac OS X (Snow Leopard/Lion), 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 OS/arch combination you may want to try installing from source or installing gccgo instead of gc.

Install the Go tools

The Go binary distributions assume they will be installed in /usr/local/go (or c:\Go under Windows), but it is possible to install them in a different location. If you do this, you will need to set the GOROOT environment variable to that directory when using the Go tools.

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

Windows users should read the section about setting environment variables under Windows.

FreeBSD, Linux, and Mac OS X tarballs

If you are upgrading from an older version of Go you must first remove the existing version from /usr/local/go:

rm -r /usr/local/go

Extract the archive into /usr/local, creating a Go tree in /usr/local/go:

tar -C /usr/local -xzf go1.0.2.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

Mac OS X package installer

Open the package file 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.

Windows

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 experimental MSI installer that configures your installation automatically.

Zip archive

Extract the zip file to 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 to your PATH environment variable.

MSI installer (experimental)

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.

Setting environment variables under Windows

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.

Test your installation

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.

What's next

Start by taking A Tour of Go.

For more detail about the process of building and testing Go programs read How to Write Go Code.

Build a web application by following the Wiki Tutorial.

Read Effective Go to learn about writing idiomatic Go code.

For the full story, consult Go's extensive documentation.

Subscribe to the golang-announce mailing list to be notified when a new stable version of Go is released.

Community resources

For real-time help, there may be users or developers on #go-nuts on the Freenode IRC server.

The official mailing list for discussion of the Go language is Go Nuts.

Bugs should be reported using the Go issue tracker.