|
|
@ -944,8 +944,21 @@ prompt_go_version() {
|
|
|
|
local -a match
|
|
|
|
local -a match
|
|
|
|
[[ $_P9K_RETVAL == (#b)*(go[[:digit:].]##)* ]] || return
|
|
|
|
[[ $_P9K_RETVAL == (#b)*(go[[:digit:].]##)* ]] || return
|
|
|
|
local v=$match[1]
|
|
|
|
local v=$match[1]
|
|
|
|
local p=${GOPATH:-$(go env GOPATH 2>/dev/null)}
|
|
|
|
local p=$GOPATH
|
|
|
|
[[ -n $p && $PWD/ == $p/* ]] || return
|
|
|
|
if [[ -z $p ]]; then
|
|
|
|
|
|
|
|
if [[ -d $HOME/go ]]; then
|
|
|
|
|
|
|
|
p=$HOME/go
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
p=$(command go env GOPATH 2>/dev/null) && [[ -n $p ]] || return
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $PWD/ != $p/* ]]; then
|
|
|
|
|
|
|
|
local dir=$PWD
|
|
|
|
|
|
|
|
while [[ ! -e $dir/go.mod ]]; do
|
|
|
|
|
|
|
|
[[ $dir == / ]] && return
|
|
|
|
|
|
|
|
dir=${dir:h}
|
|
|
|
|
|
|
|
done
|
|
|
|
|
|
|
|
fi
|
|
|
|
"$1_prompt_segment" "$0" "$2" "green" "grey93" "GO_ICON" 0 '' "${v//\%/%%}"
|
|
|
|
"$1_prompt_segment" "$0" "$2" "green" "grey93" "GO_ICON" 0 '' "${v//\%/%%}"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|