Installing Google Go on Linux Ubuntu

2009
22
Nov
1

One command install, Bash script to install Google Go in one Go

#!/bin/bash
ARCH=386 #CHANGE this setting to amd64 if you are on 64 bit.
sudo apt-get install bison make gcc libc6-dev ed mercurial
{
cat ~/.bashrc; cat <<EOF
export GOROOT=$HOME/go
export GOARCH=$ARCH
export GOOS=linux
export GOBIN=$HOME/gobin
export PATH=$PATH:$GOBIN
EOF
}  > ~/temp.bashrc
 
mv ~/.bashrc ~/.bashrc.old
mv ~/temp.bashrc ~/.bashrc
 
export GOROOT=$HOME/go
export GOARCH=$ARCH
export GOOS=linux
export GOBIN=$HOME/gobin
export PATH=$PATH:$GOBIN
 
mkdir $GOBIN
hg clone -r release https://go.googlecode.com/hg/ $GOROOT
cd $GOROOT/src
./all.bash

OR

Installing Pre-Requisites

  • The following packages are required for installing Google Go : bison, make, gcc, libc6-dev, ed, mercurial. To install run the command
    sudo apt-get install bison make gcc libc6-dev ed mercurial
  • Edit the .bashrc file to set up the environment variables, .bashrc file resides in your home folder (/home/username/). Add the following lines if you are using ubuntu x86 (or unsure)
    export GOROOT=$HOME/go
    export GOARCH=386
    export GOOS=linux
    export GOBIN=$HOME/gobin
    export PATH=$PATH:$GOBIN

    If you are using 64bit ubuntu version append the following lines instead

    export GOROOT=$HOME/go
    export GOARCH=amd64
    export GOOS=linux
    export GOBIN=$HOME/gobin
    export PATH=$PATH:$GOBIN

  • exit the terminal and restart OR run the bash command
  • Get the source files by running hg clone -r release https://go.googlecode.com/hg/ $GOROOT
  • cd $GOROOT/src
  • mkdir $GOBIN
  • ./all.bash
  • Now Go should be installed to the $GOBIN Directory.

Now you are ready to Go-nuts with Go!


Similar Posts
Related Searches




Comments

for Cent OS

do yum install instead of apt-get install

Post new comment

The content of this field is kept private and will not be shown publicly.