From 1ed1502f9e52a0df2a4a4258f530f3da9a0ec3cf Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Wed, 21 Oct 2020 10:06:55 +0100 Subject: [PATCH] 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. --- zsh/golang.zsh | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/zsh/golang.zsh b/zsh/golang.zsh index fb20c29..a18e32f 100755 --- a/zsh/golang.zsh +++ b/zsh/golang.zsh @@ -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 # ==============================================================================