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.
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.
The Go binary distributions assume they will be installed in
/usr/local/go
, 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
On FreeBSD and Linux, 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 go.release.go1.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
Open the .pkg
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.
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.
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.
Start by taking A Tour of Go or reading the Go Tutorial.
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.
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.