Mac配置gopath 好简单啊
程序员文章站
2022-06-03 22:59:53
...
首先安装zsh
https://www.cnblogs.com/EasonJim/p/6283247.html
然后设置zshrc
vi ~/.zshrc
export ZSH=$HOME/.oh-my-zsh
ZSH_THEME="robbyrussell"
plugins=(git)
ZSH_THEME="amuse"
source $ZSH/oh-my-zsh.sh
function setgopath() {
currpath=`pwd`
gopath=${currpath%/src*}
if [[ $currpath != $gopath ]];then
if [[ $gopath != $GOPATH ]];then
export GOPATH=$gopath
echo '$GOPATH:'$GOPATH
fi
fi
}
setgopath
function cd_and_setgopath() {
cd $1
setgopath
}
alias cd='cd_and_setgopath'
完成了 是不是很简单
然后你只要创建类似 foo/src/foo src/foo 这样的结构 当cd到src目录的时候gopath自动转换
下一篇: Windows用户态调试技术