Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for the GOBIN environment variable for each Go version. #107

Closed
BorzdeG opened this issue Jun 27, 2023 · 5 comments · Fixed by #139
Closed

Support for the GOBIN environment variable for each Go version. #107

BorzdeG opened this issue Jun 27, 2023 · 5 comments · Fixed by #139

Comments

@BorzdeG
Copy link

BorzdeG commented Jun 27, 2023

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 added a commit to BorzdeG/asdf-golang that referenced this issue Jun 27, 2023
@ankitcharolia
Copy link

@BorzdeG Kindly try out this goenv: https://github.com/ankitcharolia/goenv

@BorzdeG
Copy link
Author

BorzdeG commented Aug 28, 2023

@ankitcharolia Why install something else when it can be solved with one utility?

@lothar1998
Copy link
Contributor

lothar1998 commented Mar 8, 2024

@BorzdeG

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!

@ctsstc
Copy link

ctsstc commented Apr 5, 2024

@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?

@lothar1998
Copy link
Contributor

lothar1998 commented Jul 10, 2024

@ctsstc It seems that it installs the binary into $GOROOT/bin so I believe the fix I proposed should help. Please take a look at #139.

BorzdeG added a commit to BorzdeG/asdf-golang that referenced this issue Jul 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

4 participants