ipld-eth-server/vendor/github.com/ipfs/go-ipfs/bin/check_go_path
2019-12-02 13:24:46 -06:00

31 lines
529 B
Bash
Executable File

#!/usr/bin/env bash
set -e
PKG="$1"
DIR="$(pwd -P)"
GOPATH="$(go env GOPATH)"
# The path separator is ; on windows.
if [ "$(go env GOOS)" = "windows" ]; then
PATHSEP=';'
else
PATHSEP=':'
fi
while read -r -d "$PATHSEP" p; do
if ! cd "$p/src/$PKG" 2>/dev/null; then
continue
fi
if [ "$DIR" = "$(pwd -P)" ]; then
exit 0
fi
cd "$DIR"
done <<< "$GOPATH$PATHSEP"
echo "go-ipfs must be built from within your \$GOPATH directory."
echo "expected within '$GOPATH' but got '$DIR'"
exit 1