Support for the GOBIN environment variable for each Go version.
BorzdeG opened this issue · 5 comments
By default, if GOBIN
is not set, it is not guaranteed that the path $GOPATH/bin
will be used - it is better to set it explicitly in the Environment
@BorzdeG Kindly try out this goenv: https://github.com/ankitcharolia/goenv
@ankitcharolia Why install something else when it can be solved with one utility?
I feel like modifying the set-env.zsh
script can help (of course for ZSH):
asdf_update_golang_env() {
local go_path
go_path="$(asdf which go)"
if [[ -n "${go_path}" ]]; then
export GOROOT
GOROOT="$(dirname "$(dirname "${go_path:A}")")"
# the next two lines should be added to the original script
export GOBIN
GOBIN="$(dirname "$(dirname "${go_path:A}")")/bin"
fi
}
autoload -U add-zsh-hook
add-zsh-hook precmd asdf_update_golang_env
This modification worked for me. Please let me know your thoughts!
@lothar1998 this is what I was just about to do, but wanted to see what others were doing or if I was the only one with this issue. I ran go env
and my GOBIN
is an empty string. I'm still not certain where go install
is installing to if it's an empty string 🤷 I thought it was supposed to default off of the GOROOT
, but that seems it may not be the case?