Skip to main content

Go Programming Language: Installation

The Go Programming Language 
 Build version go1


Installing a binary distribution of the gc compiler

Getting Started

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.

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.

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.

Comments

Popular posts from this blog

CloverETL Designer4.9 Quick Start

Command go

Command go Compile packages and dependencies Remove object files Run godoc on package sources Print Go environment information Run go tool fix on packages Run gofmt on package sources Download and install packages and dependencies Compile and install packages and dependencies List packages Compile and run Go program Test packages Run specified go tool Print Go version Run go tool vet on packages GOPATH environment variable Description of package lists Remote import path syntax Description of testing flags Description of testing functions Go is a tool for managing Go source code. Usage: go command [arguments] The commands are: build compile packages and dependencies clean remove object files doc run godoc on package sources env print Go environment information fix run go tool fix on packages fmt run gofmt on package sources get download and install packages and dependencies install compile and install packages