Created
October 14, 2016 16:31
-
-
Save burdenless/263135bd5b53b85d57b8f3ab3248d38c to your computer and use it in GitHub Desktop.
Install and setup a Golang workspace on OSX
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#### Script to bootstrap a Golang workspace on OSX #### | |
####################################################### | |
# DL and Install ###################################### | |
brew install go | |
# Set up directory structure ########################## | |
GODIR_DEFAULT="$HOME/Code/go" | |
echo "Location to install Go (default: $HOME/Code/go) [RETURN to use default]: " | |
read GODIR | |
if [[ -z $GODIR ]]; then | |
GODIR=$GODIR_DEFAULT | |
echo "Using default: $GODIR" | |
fi | |
echo "GitHub username: " | |
read GHUSER | |
echo "=> Creating directory structure at: $GODIR" | |
mkdir -p $GODIR | |
mkdir -p $GODIR/src | |
mkdir -p $GODIR/pkg | |
mkdir -p $GODIR/bin | |
mkdir -p $GODIR/src/github.com/$GHUSER | |
# Set up environment vars ############################# | |
echo "=> Exporitng env variables" | |
echo "# Golang env" >> ~/.bash_profile | |
echo "export GOPATH=$GODIR" >> ~/.bash_profile | |
echo "export GOROOT=/usr/local/opt/go/libexec" >> ~/.bash_profile | |
echo "export GOBIN=$GODIR/bin" >> ~/.bash_profile | |
`source ~/.bash_profile` | |
export PATH=$PATH:$GOPATH/bin | |
export PATH=$PATH:$GOROOT/bin | |
# Verify installation | |
go get golang.org/x/tools/cmd/godoc | |
echo "=> Setup Complete!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment