Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ensure you are not using replaced package in go.mod.
#!/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
You can’t perform that action at this time.