Last active
March 17, 2023 06:54
-
-
Save jmhungdev/72dfd0899f77edf16140bd83dadaa623 to your computer and use it in GitHub Desktop.
rename go module and update import paths
This file contains 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 | |
OLD_MODULE_NAME=jmhungdev/go-example | |
NEW_MODULE_NAME=jmhundev/go-lessons | |
# replace module name in go.mod | |
go mod edit -module $NEW_MODULE_NAME | |
# find all .go files in current dir and sub dirs | |
# for each file replace old module name with the new one in place | |
find . -type f -name '*.go' \ | |
-exec sed -i '' -e 's/$OLD_MODULE_NAME/$NEW_MODULE_NAME/g' {} \; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment