Pages

Thursday, April 2, 2015

Install Go Programming Language in Ubuntu

Download the latest stable source code goX.X.X.src.tar.gz from https://golang.org/doc/install/source .
Extract "go" folder from the goX.X.X.src.tar.gz to home directory.


Edit file .bashrc and add:
export GOROOT=$HOME/go
export PATH=$PATH:$GOROOT/bin
Based on my OS (Ubuntu 14.04 64 bit), also add:
export GOARCH=amd64
export GOOS=linux

First make sure gcc and libc6-dev already installed. From terminal:
sudo apt-get install gcc libc6-dev

Now build from ~/go/src by executing all.bash


When done building, it shows:


And 3 new folder showed after installation


Then create folder named "gocode" in home directory, and write file hello.go to test the installation by running command "go run hello.go".