Created
September 6, 2013 12:32
-
-
Save jamiehannaford/6463138 to your computer and use it in GitHub Desktop.
The convention for Go working environments is to clump everything in one "Gopath" - which kind of acts as a universal environment. But I don't like that; if I'm working on multiple Git projects, I might want a completely separate environment with separate packages and a src directory just for my project. Maybe I'm wrong but this seems to work. N…
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
#!/bin/bash | |
subdir=${1%/} | |
if [ ! $subdir ]; then | |
echo "Please specify an argument" | |
exit | |
fi | |
dir="${PWD}/$subdir" | |
if [ ! -d "$dir" ]; then | |
echo "$dir does not exist" | |
exit | |
fi | |
stripped=$(echo ${PATH} | awk -v RS=: -v ORS=: "/${GOPATH##*/}/ {next} {print}" | sed 's/:*$//') | |
if [ ! $stripped ]; then | |
stripped=$PATH | |
fi | |
export GOPATH=$dir | |
export PATH=$stripped:$dir/bin |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment