Skip to content

Instantly share code, notes, and snippets.

@jaymecd
Created August 27, 2017 19:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaymecd/b232d8ac238c06b8a28b78b69a154b13 to your computer and use it in GitHub Desktop.
Save jaymecd/b232d8ac238c06b8a28b78b69a154b13 to your computer and use it in GitHub Desktop.
OSX brew-like GO apps install
#!/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