Here is the enterprise version
https://github.com/cxreg/smartcd
I only needed this
https://github.com/alecthomas/ondir
Macs can brew install ondir, I guess there must be some linux install.
Then you add the script.sh contents to your .bash_profile
Next you create a ~/.ondirrc file
enter ~/code/letmegrpc
export GOPATH=$ONDIRWD
echo "Switched GOPATH to $GOPATH"
export PATH=$GOPATH/bin:$PATH
echo "Prepended $GOPATH/bin to PATH"
enter ~/code/gopath
export GOPATH=$ONDIRWD
echo "Switched GOPATH to $GOPATH"
export PATH=$GOPATH/bin:$PATH
echo "Prepended $GOPATH/bin to PATH"
Log out and Log into your console
Now when you cd to a folder your GOPATH and PATH will be set automatically.