Text Editor

The name and version of text editors can vary on different operating systems. For example, Notepad is used on Windows, and vim or vi is used on Windows as well as Linux or UNIX.

The files you create with the text editor are called source files. They contain program source code. The source files for Go programs are typically named with the extension ".go".

Before starting your programming, make sure you have a text editor in place and you have enough experience to write a computer program, save it in a file, compile it, and finally execute it.

The Go Compiler

The source code written in source file is the human readable source for your program. It needs to be compiled and turned into machine language so that your CPU can actually execute the program as per the instructions given. The Go programming language compiler compiles the source code into its final executable program.

The following section explains how to install Go binary distribution on various OS.

Download Go Archive

Download the latest version of Go installable archive file from Go Downloads. The following version is used in this tutorial: go1.4.windows-amd64.msi.

It is copied it into C:\>go folder.

OS

Archive name

Windows

go1.4.windows-amd64.msi

Linux

go1.4.linux-amd64.tar.gz

Mac

go1.4.darwin-amd64-osx10.8.pkg

FreeBSD

go1.4.freebsd-amd64.tar.gz

Installation on UNIX/Linux/Mac OS X, and FreeBSD

Extract the download archive into the folder /usr/local, creating a Go tree in /usr/local/go. For example −

tar -C /usr/local -xzf go1.4.linux-amd64.tar.gz

Add /usr/local/go/bin to the PATH environment variable.

OS

Output

Linux

export PATH = $PATH:/usr/local/go/bin

Mac

export PATH = $PATH:/usr/local/go/bin

FreeBSD

export PATH = $PATH:/usr/local/go/bin

Installation on Windows

Use the MSI file and follow the prompts to install the Go tools. By default, the installer uses the Go distribution in c:\Go. The installer should set the c:\Go\bin directory in Window's PATH environment variable. Restart any open command prompts for the change to take effect.