Skip to content

Instantly share code, notes, and snippets.

@boopathi
Created July 11, 2013 11:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save boopathi/5974801 to your computer and use it in GitHub Desktop.
Save boopathi/5974801 to your computer and use it in GitHub Desktop.
Set Golang environment before you start compiling go code
#!/bin/bash
###
#
# @usage `source set_env.sh`
# @desc Sets the environment for developers
# @install Put this file into the GO Workspace directory
#
# bash-$ ls workspace/go/
# - set_env.sh*
# - bin/
# - src/
# - tmp/
# - pkg/
#
###
#Get the script's own directory instead of where it's being called from
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Set PATH
if [[ "$PATH" != ?(*:)"$DIR/bin"?(:*) ]]; then
export PATH=$PATH:$DIR/bin
fi
# Set GOPATH - used by GO
if [[ -z "$GOPATH" ]]; then
export GOPATH=$DIR
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment