A CLI tool to replace Go import paths across your entire project.
go install github.com/Lunaryx-org/refx@latest
refx <old-import-path> <new-import-path>
When moving a project from personal account to organization:
refx github.com/private/myproject github.com/myorg/myproject
This will:
- Find all .go files in the current directory and subdirectories
- Replace old import paths with new ones
- Safely update files using atomic file operations
- Moving repositories between GitHub accounts
- Renaming your GitHub username
- Migrating from GitLab to GitHub (or vice versa)
- Refactoring internal import paths
refx scans all .go files recursively, finds lines containing the old import path, replaces them with the new path, and atomically updates each file to ensure data integrity.
Each file is written to a temporary file first, then atomically renamed to replace the original. This ensures that if anything goes wrong, your original files remain intact.
- Add a verbose flag --verbose for more explained output
- Better output formatting with progress indicators
- Automatic backup before making changes
- Ignore golang keywords
- --dry-run flag to preview changes
- Color-coded output
- Statistics summary
- Only work on files that have that import path / ignore irevelant golang files
- Config file to apply rules if specified
MIT
Gustavo Pereira ([email protected])
.png)


