Created
September 14, 2020 05:58
-
-
Save ysugimoto/8e63d6ad569c2ba2dcb5631ec26a2dc3 to your computer and use it in GitHub Desktop.
Ensure you are not using replaced package in go.mod.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
findup () { | |
CWD=$1 | |
while [ "$CWD" != "/" ]; do | |
if [ -f "$CWD/go.mod" ]; then | |
echo "$CWD/go.mod" | |
return 0 | |
fi | |
CWD=$(dirname $CWD) | |
done | |
echo "Could not find go.mod in your directry tree" | |
exit 1 | |
} | |
MODFILE=$(findup $PWD) | |
if [ $? = "0" ]; then | |
FOUND=$(cat $MODFILE | grep -e "^replace") | |
if [ "$FOUND" != "" ]; then | |
echo "Your Go project is using replaced package!" | |
echo "Make sure you are using package which is placed in exteranal host." | |
exit 1 | |
fi | |
exit 0 | |
else | |
echo $MODFILE | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment