Your download should begin shortly. If it does not, click this link.
Introduction
Go is an open source project, distributed under a BSD-style license. This document explains how to check out the sources, build them on your own machine, and run them.
Most users don't need to do this, and will instead install from precompiled binary packages as described inGetting Started, a much simpler process. If you want to help develop what goes into those precompiled packages, though, read on.
gcgccgo
The Go compilers support seven instruction sets. There are important differences in the quality of the compilers for the different architectures.
amd64x86-64386x86x86-32amd64gccgoarmARMarm64AArch64ppc64, ppc64lemips64, mips64les390x
Except for things like low-level operating system interface code, the run-time support is the same in all ports and includes a mark-and-sweep garbage collector, efficient array and string slicing, and support for efficient goroutines, such as stacks that grow and shrink on demand.
The compilers can target the DragonFly BSD, FreeBSD, Linux, NetBSD, OpenBSD, OS X (Darwin), Plan 9, Solaris and Windows operating systems. The full set of supported combinations is listed in the discussion ofenvironment variables below.
See the main installation page for the overall system requirements. The following additional constraints apply to systems that can be built only from source:
For Linux on PowerPC 64-bit, the minimum supported kernel version is 2.6.37, meaning that Go does not support CentOS 6 on these systems.
Install Go compiler binaries
$GOROOT_BOOTSTRAPGOROOT_BOOTSTRAP$HOME/go1.4
GOROOT_BOOTSTRAP$GOROOT_BOOTSTRAP/bin/gogo
To use a binary release as a bootstrap tool chain, see the downloads page or use any other packaged Go distribution.
release-branch.go1.4
linux/ppc64le
When run as (for example)
$ GOOS=linux GOARCH=ppc64 ./bootstrap.bash
bootstrap.bashGOOS/GOARCH../../go-${GOOS}-${GOARCH}-bootstrapGOROOT_BOOTSTRAP
$GOROOT_BOOTSTRAP/bin/go
$ sudo apt-get install gccgo-5 $ sudo update-alternatives --set go /usr/bin/go-5 $ GOROOT_BOOTSTRAP=/usr ./make.bash
Install Git, if needed
git
If you do not have a working Git installation, follow the instructions on the Git downloads page.
(Optional) Install a C compiler
gccclang
cgoCGO_ENABLED=0all.bashmake.bash
Fetch the repository
gogogo1.7.5
$ git clone https://go.googlesource.com/go $ cd go $ git checkout go1.7.5
(Optional) Switch to the master branch
If you intend to modify the go source code, and contribute your changes to the project, then move your repository off the release branch, and onto the master (development) branch. Otherwise, skip this step.
$ git checkout master
Install Go
To build the Go distribution, run
$ cd src $ ./all.bash
all.bat
If all goes well, it will finish by printing output like:
ALL TESTS PASSED --- Installed Go for linux/amd64 in /home/you/go. Installed commands in /home/you/go/bin. *** You need to add /home/you/go/bin to your $PATH. ***
where the details on the last few lines reflect the operating system, architecture, and root directory used during the install.
all.bashall.batmake.bashmake.bat
Testing your installation
Check that Go is installed correctly by building a simple program.
hello.go
package main import "fmt" func main() { fmt.Printf("hello, world\n") }
go
$ go run hello.go hello, world
If you see the "hello, world" message then Go is installed correctly.
Set up your work environment
You're almost done. You just need to do a little more setup.
The How to Write Go Code document provides essential setup instructions for using the Go tools.
Install additional tools
goget
$ go get golang.org/x/tools/cmd/...
godoc
$ go get golang.org/x/tools/cmd/godoc
goget
GOPATH
gogodoc$GOROOT/bin$GOBINcovervet$GOROOT/pkg/tool/$GOOS_$GOARCHgotoolcovergotoolvet
Community resources
#go-nuts
Bugs can be reported using the Go issue tracker.
Keeping up with releases
go1.7.5
To update an existing tree to the latest release, you can run:
$ cd go/src $ git fetch $ git checkout go1.7.5
Optional environment variables
The Go compilation environment can be customized by environment variables. None is required by the build, but you may wish to set some to override the defaults.
$GOROOT$HOME/goall.bash$GOROOT_FINAL$GOROOT$GOROOT$GOROOT_FINAL$GOOS$GOARCH$GOHOSTOS$GOHOSTARCH$GOOSdarwindragonflyfreebsdlinuxnetbsdopenbsdplan9solariswindows$GOARCHamd64386armarm64ppc64leppc64mips64lemips64$GOOS$GOARCH$GOOS$GOARCHandroidarmdarwin386darwinamd64darwinarmdarwinarm64dragonflyamd64freebsd386freebsdamd64freebsdarmlinux386linuxamd64linuxarmlinuxarm64linuxppc64linuxppc64lelinuxmips64linuxmips64lenetbsd386netbsdamd64netbsdarmopenbsd386openbsdamd64openbsdarmplan9386plan9amd64solarisamd64windows386windowsamd64$GOHOSTOS$GOHOSTARCH$GOOS$GOARCH$GOHOSTARCHarm$GOBIN$GOROOT/bin$PATH$GOBIN$GO386386386amd64387387sse2GO386=387GO386=sse2$GOARMarmGOARM=5GOARM=6GOARM=7
$GOARCH$GOOSGOARCH386amd64
$HOME/.bashrc$HOME/.profile
export GOROOT=$HOME/go export GOARCH=amd64 export GOOS=linux
although, to reiterate, none of these variables needs to be set to build, install, and develop the Go tree.