Read and Do: Downloading and Installing Go

Downloading Go

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

Install the Go tools

Read through the installation guide for Linux, Mac OS X, FreeBSD and Windows.

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

Warning: GOROOT must be set only when installing to a custom location.

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.

The Go-environment works with a small number of OS environment variables. They are not required for building the Go-environment, but by setting them and thus overriding the defaults the Go compilation environment can be customized. I have set the following:

GOROOT to C:\go
GOOS to windows
GOARCH to 386

Environment Variables

On Windows:

In the same dialog-window: Edit the PATH-variable as follows:

C:\go\bin; ...rest of PATH...

Test your installation

Check that Go is installed correctly by building a simple program, as follows.

Create a file named hello_world.go in some folder (for now) and put the following program in it:

package main

import "fmt"

func main() {
        fmt.Println("Hello, world.")
}

Then from the folder where you have saved the file hello_world.go run it with the go tool:

$ go run hello_world.go
Hello, world.

If you see the "Hello, world." message then your Go installation is working.

  •  
  •  
  •  
  • Draft
  • Action
  • Audio
  • Blog Post
  • Reading
  • Video
  • Question
  • Poll
  • Quiz
  • Slides
  •  
  •  
  •  
  • Draft
  • Action
  • Audio
  • Blog Post
  • Reading
  • Video
  • Question
  • Poll
  • Quiz
  • Slides
  •  
  •  
  •  
  • Draft
  • Action
  • Audio
  • Blog Post
  • Reading
  • Video
  • Question
  • Poll
  • Quiz
  • Slides
  •  
  •  
  •  
  • Draft
  • Action
  • Audio
  • Blog Post
  • Reading
  • Video
  • Question
  • Poll
  • Quiz
  • Slides
  •  
  •  
  •  
  • Draft
  • Action
  • Audio
  • Blog Post
  • Reading
  • Video
  • Question
  • Poll
  • Quiz
  • Slides
  •  
  •  
  •  
  • Draft
  • Action
  • Audio
  • Blog Post
  • Reading
  • Video
  • Question
  • Poll
  • Quiz
  • Slides
  •  
  •  
  •  
  • Draft
  • Action
  • Audio
  • Blog Post
  • Reading
  • Video
  • Question
  • Poll
  • Quiz
  • Slides
  •  
  •  
  •  
  • Draft
  • Action
  • Audio
  • Blog Post
  • Reading
  • Video
  • Question
  • Poll
  • Quiz
  • Slides
  •  
  •  
  •  
  • Draft
  • Action
  • Audio
  • Blog Post
  • Reading
  • Video
  • Question
  • Poll
  • Quiz
  • Slides

This Step is Empty. Add to it!

 
Course Complete