2024-02-28 23:22:33 +03:00
|
|
|
#!/bin/zsh
|
|
|
|
|
|
|
|
z-gobin-fixup() {
|
|
|
|
(( ${+commands[go]} )) || return 0
|
2024-03-04 15:35:55 +03:00
|
|
|
|
2024-02-28 23:22:33 +03:00
|
|
|
local gobin
|
2024-03-04 15:35:55 +03:00
|
|
|
gobin=$(command go env GOBIN)
|
2024-02-28 23:22:33 +03:00
|
|
|
if [ -z "${gobin}" ] ; then
|
|
|
|
local gopath
|
2024-03-04 15:35:55 +03:00
|
|
|
gopath=$(command go env GOPATH)
|
2024-02-28 23:22:33 +03:00
|
|
|
[ -n "${gopath}" ] || return 1
|
|
|
|
[ -d "${gopath}" ] || return 0
|
|
|
|
gobin="${gopath}/bin"
|
|
|
|
fi
|
|
|
|
[ -d "${gobin}" ] || mkdir "${gobin}" || return 1
|
|
|
|
## already in PATH?
|
|
|
|
[ "${path[(I)${gobin}]}" = 0 ] || return 0
|
|
|
|
path=( "${gobin}" ${path} )
|
|
|
|
hash -f
|
|
|
|
}
|
|
|
|
|
|
|
|
z-gobin-fixup
|