Skip to content

Instantly share code, notes, and snippets.

@bldrdash
Created March 13, 2024 22:00
Show Gist options
  • Save bldrdash/958b856549d0af45dffcb50f692b9c1d to your computer and use it in GitHub Desktop.
Save bldrdash/958b856549d0af45dffcb50f692b9c1d to your computer and use it in GitHub Desktop.
Rename golang module
#!/bin/bash
if [ -z "$1" -o -z "$2" ]; then
echo $0 oldmod newmod
exit 1
fi
OLD_MODULE="$1"
NEW_MODULE="$2"
if [ ! -f go.mod ]; then
echo "Could not find go.mod"
exit 1
fi
sed -i -e "s,${OLD_MODULE},${NEW_MODULE},g" go.mod
find . -type f -name '*.go' -exec sed -i -e "s,${OLD_MODULE},${NEW_MODULE},g" {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment