Created
July 29, 2017 17:33
-
-
Save tpfwrz/55f222074ade780a8a8f12d866b13595 to your computer and use it in GitHub Desktop.
virtualenv for golang
This file contains hidden or 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
| #!/usr/bin/env bash | |
| mkdir $1 | |
| echo '# This file must be used with "source activate" or ". activate" | |
| function deactivate() { | |
| if [ -n "$GOENVNAME" ]; then | |
| unset GOENVNAME | |
| fi | |
| if [ -n "$_OLD_GOROOT" ]; then | |
| export GOROOT="$_OLD_GOROOT" | |
| unset _OLD_GOROOT | |
| fi | |
| if [ -n "$_OLD_PS1" ]; then | |
| export PS1="$_OLD_PS1" | |
| unset _OLD_PS1 | |
| fi | |
| if [ -n "$_OLD_PATH" ]; then | |
| export PATH="$_OLD_PATH" | |
| unset _OLD_PATH | |
| fi | |
| if [ -n "$_OLD_GOPATH" ]; then | |
| export GOPATH="$_OLD_GOPATH" | |
| export GOBIN="$_OLD_GOPATH"/bin | |
| unset _OLD_GOPATH | |
| fi | |
| if [ "$1" != "init" ]; then | |
| unset -f deactivate | |
| fi | |
| } | |
| deactivate init | |
| export _OLD_PATH="$PATH" | |
| export _OLD_GOPATH="$GOPATH" | |
| export _OLD_GOROOT="$GOROOT" | |
| export _OLD_PS1="$PS1" | |
| export GOENVNAME='$1' | |
| export PS1="(go:$GOENVNAME) $_OLD_PS1" | |
| export GOPATH=$(pwd)/$GOENVNAME | |
| export GOBIN=$GOPATH/bin | |
| export PATH="$GOBIN":$PATH' > $1/activate2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment