Snippets

Paweł R Install golang

Created by Paweł R
echo "Enter your golang path (ex: $HOME/golang) :"
read gopath

echo "Enter your github username (pawelropa, mikesomethin etc)"
read user


echo "Creating gopath directory"
mkdir $gopath

echo "Creating directory for github user"
mkdir -p $gopath/src/github.com/$user

echo "Exporting environemt variables"
export GOPATH=$gopath
export GOROOT=/usr/local/opt/go/libexec
export PATH=$PATH:$GOPATH/bin
export PATH=$PATH:$GOROOT/bin

echo "Checking for brew"
command -v brew >/dev/null 2>&1 || { ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" }

echo "Updating brew"
brew update

echo "Installing go"
brew install go

echo "Installing git"
brew install git

echo "Installing mercurial"
brew install mercurial

echo "Fetching additional golang packages"
go get golang.org/x/tools/cmd/godoc
go get golang.org/x/tools/cmd/vet

echo "Golang installed successfully!"

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.