Created
August 27, 2017 19:55
-
-
Save jaymecd/b232d8ac238c06b8a28b78b69a154b13 to your computer and use it in GitHub Desktop.
OSX brew-like GO apps install
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -euo pipefail | |
if [[ $# -lt 1 ]]; then | |
echo "Usage: brew-go-get github.com/foo/bar ..." | |
exit 1 | |
fi | |
NAME=$(basename "${1}") | |
VERSION=$(date '+%Y.%m.%d') | |
export GOPATH="$(brew --prefix)/Cellar/go-get-${NAME}/${VERSION}" | |
mkdir -p "${GOPATH}" | |
echo "$(basename $0) $@" > "${GOPATH}/install.cmd" | |
go get -u -v "$@" | |
rm -rf "${GOPATH}/pkg" "${GOPATH}/src" | |
brew unlink "go-get-${NAME}" >/dev/null 2>/dev/null || true | |
brew switch "go-get-${NAME}" "${VERSION}" || brew link --overwrite "go-get-${NAME}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment