asdf-golang
asdf-golang copied to clipboard
GOBIN should be set when installing default pkgs on go > 1.16
Describe the bug GOBIN is not set when install default-golang-pkgs. and thus go install new binaries into current version of go's GOBIN instead of new GOBIN.
To Reproduce Steps to reproduce the behavior:
- asdf install golang 1.24rc2
- check
$(env ASDF_GOLANG_VERSION=1.24rc2 go env GOBIN)
- the directory
~/.asdf/installs/golang/1.24rc2/bin
does not exists - current version of golang insall's GOBIN is updated. for example i'm using 1.23.5 for now, binaries inside
.asdf/installs/golang/1.23.5/bin
are updated
Expected behavior asdf install golang VERSION should install binaries into ~/.asdf/installs/golang/$VERSION/bin
Screenshots If applicable, add screenshots to help explain your problem.
Additional context
after some investigation, GOBIN is set for each go version since 962a601cbdeb7ea9bc18afb5879bfe5d0b47d307 , but not used in install scripts. add GOROOT="$ASDF_INSTALL_PATH/go" GOPATH="$ASDF_INSTALL_PATH/packages" PATH="$go_path:$PATH" go env GOBIN
in install script will show that the GOBIN directory does not match the new installed version
suggest: add GOBIN in bin/install like this:
diff --git a/bin/install b/bin/install
index b196283..eea3093 100755
--- a/bin/install
+++ b/bin/install
@@ -51,6 +51,7 @@ install_default_go_pkgs() {
GOROOT="$ASDF_INSTALL_PATH/go" \
GOPATH="$ASDF_INSTALL_PATH/packages" \
+ GOBIN="$ASDF_INSTALL_PATH/bin" \
PATH="$go_path:$PATH" \
go install "$name" >/dev/null && rc=$? || rc=$?
else