navigaid
12/18/2016 - 3:25 AM

Bash script for fast setting up Golang environment

Bash script for fast setting up Golang environment

#!/bin/bash
cd
#
# Bash script for fast setting up Golang environment
#
# Usage:
#
# chmod +x setup-go.sh
#
# or
#
# curl -L http://tiny.cc/24wbkx | sh

#bashrc="$HOME/.bashrc"
arch=`uname -m`

#goroot="$HOME/go/"
#gobin=$goroot"go/bin"
#gopath=$HOME"gowork"

#if [ ! -d "$gopath" ]; then
#    mkdir $gopath
#fi

#if [ ! -d "$projects" ]; then
#    mkdir $gopath"go-projects"
#fi

#cd $gopath

mkdir gowork
cd gowork
mkdir src bin pkg
cd -


pkg_amd64="go1.7.4.linux-amd64.tar.gz"
pkg_386="go1.7.4.linux-386.tar.gz"

if [ "$arch" == "x86_64" ]; then
    wget "http://golang.org/dl/"$pkg_amd64
    tar xzf $pkg_amd64
    rm -rf $pkg_amd64
else
    wget "http://golang.org/dl/"$pkg_386
    tar xzf $pkg_386
    rm -rf $pkg_386
fi

GOPATH="$HOME/gowork
GOROOT="$HOME/go

echo "export GOPATH="$HOME/gowork >> postgo
echo "export GOROOT="$HOME/go >> postgo
echo "export PATH="$PATH":"$HOME/gowork/bin >> postgo
echo "export PATH="$PATH":"$HOME/go/bin >> postgo

echo "done extracting"
# PATH=$PATH:/$HOME/go/bin
# it worked
source postgo
echo "source postgo"

#source ~/.bashrc

exit 0