kubo/bin/check_go_path
Dominic Della Valle 7a3566b007 handle backslash paths in check_go_path
License: MIT
Signed-off-by: Dominic Della Valle <ddvpublic@gmail.com>
2018-07-20 08:35:25 -04: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