Friday, October 3, 2014

How to setup golang ( go) version 1.3 or higher on ubuntu

So the golang version 1.3 is out and now in stable mode . So you must be wondering how to setup golang to go go for fantastic code .
Below i have mentioned the steps and commands which you guys can copy paste to setup "GO 1.3" on your ubuntu machine .

1) Run these commands :
sudo apt-get install build-essential
sudo apt-get install mercurial git

2) we are using go-lang’s( or go) 1.3.0 version here, currently this url will provide the golang 1.3.0 (stable) . You can browse for all releases of golang from here :

Download the file from this url :
Run command :

Now extract its content such that home directory have a folder “go” and this folder has another folders inside it (one of them is “src”) . Now run these commands :

tar -xzf golang/go1.3.src.tar.gz
cd go/src

3) Now make a folder projects in home directory and in home directory edit file called “.bashrc”

and paste the following stuff (i have added projects folder in one of the settings here below)

and GOROOT is the home folder here , where we took the clone of go lang's source code

export GOROOT=/home/ubuntu/go export GOPATH=$HOME/projects export PATH=$PATH:$GOROOT/bin:$GOPATH/bin export PATH=$PATH:$GOPATH/bin 

4) save and reboot the system

5) now make a test folder in projects folder

cd ~/projects/
mkdir test
cd test
sudo apt-get install vim
vim test.go

paste the code given below :

package main 
import "fmt" 
func main() {     fmt.Printf("hello, world\n") 

now save it and run the command

go run test.go

if it says : hello, world

then everything is working fine .

if there is some problem like golang is not installed then check Path you set earlier in .bashrc file

Note : We have used "go" named folder in home directory , you can change location of this folder as per your wish but change the path in ".bashrc" file in step 3 as well .

No comments:

Post a Comment