Quick Overview

Go is a compiled language like C or C++, not interpreted like Python. This is course means that to do anything you need a Go compiler. Since Go is only officially available in source form, that means we’ll need to compile the Go compiler with gcc. When everything is done, you will have two Go compilers available, 6g and 8g. The only difference between them is that 6g creates 64-bit binaries and 8g creates 32-bit. Once you know which compiler you want, just code and compile for Go much like you would for gcc.
There are technically other compiler options, but 6g and 8g are the official compilers and will be used exclusively in this guide.
Update: A PPA is now available for Google Go. To install, open a terminal and type:

Preparing the System

There are a few quick easy things we’ll need to do in order to get our environment prepared. First, Go requires a few environment variables to be set in the shell so that it knows where to find and place files. You could type all the following commands directly into the terminal, but since some of them may be needed later, we’ll put them all in our .bashrc file. Open your ~/.bashrc file, and enter the following lines at the end: Then at the command line type to make sure it reads the file and creates those environment variables.

Installing Build Dependencies

We need a C compiler (such as gcc) along with some other utilities to create the Go compilers (6g and 8g). At your command prompt, run the following commands to install all needed build dependencies.

Getting and Compiling the Go Source Code

Now that we’ve got everything we need to install Go, we’re ready to get the code itself. To fetch the files, enter the following command: Your output should approximately match the following:

And now we’re ready to compile Go into a usable language. To begin, enter the following in your terminal: Remember, this part is gcc compiling Go, so this will not have the speed benefits associated with writing and compiling actual Go code and will likely take a few minutes.
If you get a message about $GOBIN, make sure you remembered to create the directory that you put in your .bashrc file. Similarly, for other errors, double check the variables you put in your .bashrc file.

Test Your Installation

Save the following into a file called test.go Now at the command line… If all went well, you should see something like this: And you’re ready to start coding!