Skip to content

Instantly share code, notes, and snippets.

@daniyel
Created June 24, 2018 08:29
Show Gist options
  • Save daniyel/207d442f6b73adf035f1ea6bd7262537 to your computer and use it in GitHub Desktop.
Save daniyel/207d442f6b73adf035f1ea6bd7262537 to your computer and use it in GitHub Desktop.
Wrapper for go dep dependency management tool to fix GOPATH for existing go project
#!/bin/sh
CURR_DIR="$(PWD)"
PARENT_DIR="$(dirname $CURR_DIR)"
export GOPATH="$(mktemp -d "/tmp/dep.XXXXXXXX")"
trap "rm -rf \"${GOPATH}\"" EXIT HUP INT
SRCDIR="${GOPATH}/src/$PARENT_DIR"
mkdir -p "$(dirname "${SRCDIR}")"
ln -s "$(pwd)" "${SRCDIR}"
cd "${SRCDIR}"
dep "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment