mirror of
https://github.com/kennyp/asdf-golang.git
synced 2024-10-05 12:12:06 +08:00
Add dynamic GOPATH settings to zsh and fish (#127)
Co-authored-by: Kenny Parnell <k.parnell@gmail.com>
This commit is contained in:
parent
d1a522ebf2
commit
0e86b1d5a7
@ -1,8 +1,9 @@
|
||||
function asdf_update_golang_env --on-event fish_prompt
|
||||
set --local go_path (asdf which go 2>/dev/null)
|
||||
if test -n "$go_path"
|
||||
set --local full_path (builtin realpath "$go_path")
|
||||
set --local go_bin_path (asdf which go 2>/dev/null)
|
||||
if test -n "$go_bin_path"
|
||||
set --local full_path (builtin realpath "$go_bin_path")
|
||||
|
||||
set -gx GOROOT (dirname (dirname "$full_path"))
|
||||
set -gx GOPATH (dirname "$GOROOT")/packages
|
||||
end
|
||||
end
|
||||
|
11
set-env.zsh
11
set-env.zsh
@ -1,9 +1,12 @@
|
||||
asdf_update_golang_env() {
|
||||
local go_path
|
||||
go_path="$(asdf which go 2>/dev/null)"
|
||||
if [[ -n "${go_path}" ]]; then
|
||||
local go_bin_path
|
||||
go_bin_path="$(asdf which go 2>/dev/null)"
|
||||
if [[ -n "${go_bin_path}" ]]; then
|
||||
export GOROOT
|
||||
GOROOT="$(dirname "$(dirname "${go_path:A}")")"
|
||||
GOROOT="$(dirname "$(dirname "${go_bin_path:A}")")"
|
||||
|
||||
export GOPATH
|
||||
GOPATH="$(dirname "${GOROOT:A}")/packages"
|
||||
fi
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user