Skip to content

Instantly share code, notes, and snippets.

@rafecolton
Created August 13, 2017 19:43
Show Gist options
  • Save rafecolton/b6657b76b85e4d7b1a872e4cb4da193a to your computer and use it in GitHub Desktop.
Save rafecolton/b6657b76b85e4d7b1a872e4cb4da193a to your computer and use it in GitHub Desktop.
brew-go-get
#!/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