forked from mongodb/mongo-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
go.sh
executable file
·35 lines (27 loc) · 843 Bytes
/
go.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
# exit on error
set -e
# cache the working dir, to return to later
workingdir=`pwd`
TOOLS_PKG='github.com/mongodb/mongo-tools'
# make sure the working directory is the root of
# the repo
SCRIPT_DIR="$(cd "$(dirname ${BASH_SOURCE[0]})" && pwd)"
cd $SCRIPT_DIR
SOURCE_GOPATH=`pwd`.gopath
VENDOR_GOPATH=`pwd`/vendor
if [ "Windows_NT" = "$OS" ]; then
SOURCE_GOPATH=$(cygpath -w $(SOURCE_GOPATH));
VENDOR_GOPATH=$(cygpath -w $(VENDOR_GOPATH));
fi
# set up the $GOPATH to use the vendored dependencies as
# well as the source for the mongo tools
rm -rf .gopath/
mkdir -p .gopath/src/"$(dirname $TOOLS_PKG)"
ln -sf `pwd` .gopath/src/$TOOLS_PKG
export GOPATH=`pwd`/.gopath:`pwd`/vendor
# go back to the original working dir
cd $workingdir
# run the go command with the specified arguments
cmd="go ${@:1}"
eval "${cmd[@]}"