Last active
July 24, 2023 10:51
-
-
Save RobRuana/7cda375014e0f699fba1 to your computer and use it in GitHub Desktop.
Change $GOPATH to current directory to quickly switch between Go workspaces
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 -l | |
# Save this file in /usr/local/bin and chmod a+x for easy access | |
# Execute gohere to switch $GOPATH to current directory | |
# Type exit to switch back | |
# Example usage: | |
# $ echo $GOPATH | |
# | |
# $ gohere | |
# (go@directory) $ echo $GOPATH | |
# /path/to/directory | |
# (go@directory) $ exit | |
# exit | |
# $ echo $GOPATH | |
# | |
# $ | |
# Set $GOPATH to current directory | |
export GOPATH=${PWD} | |
# Update command prompt to remind you which workspace you're using. | |
# This requires that your .bashrc looks for the $PROMPT_PREFIX variable | |
export PROMPT_PREFIX="(go@`basename ${PWD}`)" | |
# Start a new bash shell to inherit $GOPATH | |
bash |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment