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

Create set-env.bash #147

Merged
merged 2 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ To set `GOROOT` in your shell's initialization add the following:
Add this to your env.nu
`source ('~/.asdf/plugins/golang/set-env.nu')`

**bash shell**
Add this to your .bashrc:
`. ~/.asdf/plugins/golang/set-env.bash`

## When using `go get` or `go install`

After using `go get` or `go install` to install a package you need to run `asdf reshim golang` to get any new shims.
Expand Down
17 changes: 17 additions & 0 deletions set-env.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
asdf_update_golang_env() {
local go_bin_path
go_bin_path="$(asdf which go 2>/dev/null)"
if [[ -n "${go_bin_path}" ]]; then
abs_go_bin_path="$(readlink -f "${go_bin_path}")"

export GOROOT
GOROOT="$(dirname "$(dirname "${abs_go_bin_path}")")"

export GOPATH
GOPATH="$(dirname "${GOROOT}")/packages"

export GOBIN
GOBIN="$(dirname "${GOROOT}")/bin"
fi
}
asdf_update_golang_env