Create set-env.bash (#147)

* Create set-env.bash
* Update README.md
This commit is contained in:
Ikuo Degawa 2024-09-25 10:01:27 +09:00 committed by GitHub
parent 159af6218b
commit d4f1d65d59
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 0 deletions

View File

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

17
set-env.bash Normal file
View File

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