From d4f1d65d597ac99a0190cd7d6efecf8666cecd26 Mon Sep 17 00:00:00 2001 From: Ikuo Degawa Date: Wed, 25 Sep 2024 10:01:27 +0900 Subject: [PATCH] Create set-env.bash (#147) * Create set-env.bash * Update README.md --- README.md | 4 ++++ set-env.bash | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 set-env.bash diff --git a/README.md b/README.md index c782d65..a6c56d2 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/set-env.bash b/set-env.bash new file mode 100644 index 0000000..b491280 --- /dev/null +++ b/set-env.bash @@ -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