Created
August 13, 2017 19:43
-
-
Save rafecolton/b6657b76b85e4d7b1a872e4cb4da193a to your computer and use it in GitHub Desktop.
brew-go-get
This file contains hidden or 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
#!/bin/bash | |
# https://blog.filippo.io/cleaning-up-my-gopath-with-homebrew/ | |
set -euo pipefail | |
if [[ $# -lt 1 ]] || [[ "$1" =~ -h|--help ]] ; 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" | |
go get "$@" | |
rm -rf "$GOPATH/pkg" "$GOPATH/src" | |
brew unlink "go-get-$NAME" 2> /dev/null || true | |
brew link "go-get-$NAME" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment