fix: ensure goenv is always loaded so GOPATH is correctly set

The lazy-loading could lead to incorrect GOPATH values in sub-shells and
tmux instances which inherited a old GOPATH value from the parent
shell.

This is mostly an issue when new Go versions are installed, but it's
still an issue. Hence I now always load goenv in the background ensuring
it sets GOPATH correctly regardless of any existing GOPATH value.
This commit is contained in:
2020-10-21 10:06:55 +01:00
parent 63faaef2c0
commit 1ed1502f9e

View File

@@ -8,31 +8,14 @@
# install goenv
zinit ice wait lucid as'program' pick'bin/goenv' from'gh' \
atclone'src/configure && make -C src' atpull'%atclone' nocompile'!'
atclone'src/configure && make -C src; ../libexec/goenv init - > zgoenv.zsh' \
atpull'%atclone' src'zgoenv.zsh' nocompile'!'
zinit light syndbg/goenv
zinit ice wait lucid as'program' pick'plugins/go-build/bin/go-build' from'gh' \
id-as'syndbg/go-build'
zinit light syndbg/goenv
# lazy-load goenv
goenv() {
load-goenv
goenv "$@"
}
_goenv() {
load-goenv
_goenv "$@"
}
compctl -K _goenv goenv
load-goenv() {
unset -f load-goenv _goenv goenv
eval "$(command goenv init -)"
}
# ==============================================================================
# global golang packages
# ==============================================================================