Files
dotfiles/zsh/golang.zsh
Jim Myhrberg cd497851bd feat(mise/tools): install Go-based tools via mise again
The issue that was preventing mise from installing Go tools a few weeks
ago seems to have been resolved.
2025-02-23 23:00:00 +00:00

38 lines
919 B
Bash
Executable File

#
# Go (golang) environment setup.
#
# ==============================================================================
# global golang packages
# ==============================================================================
list_go_global_packages() {
local bindir="${GOBIN:-$(go env GOBIN)}"
if [ -z "$bindir" ]; then
echo "GOBIN is not set"
return 1
fi
for cmd in $(ls -1 "${GOBIN}"); do
go version -m "${GOBIN}/${cmd}" | grep '^[[:space:]]path' | awk '{ print $2 }'
done
}
install_go_global_packages() {
local packages=()
for package in "${packages[@]}"; do
echo "installing/updating \"$package\""
if [[ "$package" == *"@"* ]]; then
GO111MODULE=on go install "$package"
else
GO111MODULE=on go get -u "$package"
fi
done
if command-exists goenv && [ "$(goenv version-name)" != "system" ]; then
echo "running: goenv rehash..."
goenv rehash
fi
}