Skip to content

Instantly share code, notes, and snippets.

@iamucil
Last active March 28, 2025 20:37
Show Gist options
  • Save iamucil/7578dc7df7d72e1d78c8f5543db3fbcc to your computer and use it in GitHub Desktop.
Save iamucil/7578dc7df7d72e1d78c8f5543db3fbcc to your computer and use it in GitHub Desktop.
go mod edit -module {NEW_MODULE_NAME}
-- rename all imported module
find . -type f -name '*.go' \
-exec sed -i -e 's,{OLD_MODULE},{NEW_MODULE},g' {} \;
@dexterp
Copy link

dexterp commented May 5, 2024

For MACOS, Linux

#!/usr/bin/env sh

export CUR="github.com/..."
export NEW="github.com/..."
go mod edit -module ${NEW}
find . -type f -name '*.go' -exec perl -pi -e 's/$ENV{CUR}/$ENV{NEW}/g' {} \;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment