# Copy and move refactorings

> For the complete documentation index, see [llms.txt](https://www.jetbrains.com/help/go/2026.3/llms.txt).

> **Tip:**
> You can access all refactoring actions through the context menu.

Procedure: Perform copy refactoring

You can create a copy of a file, directory or a package in a different directory or a package.

1. Select an identifier that you want to refactor (for example, a file in the Project tool window). Alternatively, place the caret anywhere in your code.

2. In the main menu, go to `Refactor | Copy` or press `F5` (Windows), `F5` (macOS), `F5` (IntelliJ IDEA Classic (macOS)), `⌘ ⌥ Y` (macOS System Shortcuts), `F5` (XWin), `F5` (GNOME), `F5` (KDE), `F5` (Emacs), `F5` (Sublime Text), `F5` (Sublime Text (macOS)), `F5` (VSCode), `F5` (VSCode (macOS)).

3. In the Copy dialog, specify the name and location for your copy, and click OK.

Procedure: Perform move refactoring

You can move source code sections to another package or a file. Also, you can move a file or a folder in the Project tool window.

1. Select an identifier that you want to refactor.

2. In the main menu, go to `Refactor | Move` or press `F6` (Windows), `F6` (macOS), `F6` (IntelliJ IDEA Classic (macOS)), `⌘ ⌥ I` (macOS System Shortcuts), `F6` (XWin), `F6` (GNOME), `F6` (KDE), `F6` (Emacs), `F6` (Sublime Text), `F6` (Sublime Text (macOS)), `F6` (VSCode), `F6` (VSCode (macOS)).

3. In the Move window, you see a list of declarations that you can move along with the item. Select all the necessary declarations.

4. Specify a path to the target directory, a filename, and a package name.

[Video](https://resources.jetbrains.com/help/img/idea/2026.3/go_move_function.mp4)

> **Tip:**
> To undo the refactoring, press `Ctrl+Z` (Windows), `⌘ Z` (macOS), `⌘ Z` (IntelliJ IDEA Classic (macOS)), `⌘ Z` (macOS System Shortcuts), `Ctrl+Z` (XWin), `Ctrl+Z` (GNOME), `Ctrl+Z` (KDE), `Ctrl+Shift+Minus` (Emacs), `Ctrl+Z` (Sublime Text), `⌘ Z` (Sublime Text (macOS)), `Ctrl+Z` (VSCode), `⌘ Z` (VSCode (macOS)).

> **Note:**
> In case of conflicts, GoLand displays the Problems Detected window. Consider reviewing your changes before you apply them. To review the changes, click Show Conflicts in View.

> **Note:**
> When you move an identifier that has a related comment section, the move refactoring moves the comment section along with the identifier.

Procedure: Move private identifiers

Sometimes when you move an identifier that is not exported (a private identifier), the identifier becomes inaccessible for the source package (from which we perform the move).

GoLand displays a notification when the identifier is private and is not exported during the move operation. Before you apply code changes, consider reviewing them by using the Preview button.

![Move private identifiers](https://resources.jetbrains.com/help/img/idea/2026.3/goland_move_private_identifiers.png)

## Reference for dialog controls

| Item | Description |
| --- | --- |
| Declarations |  Specify declarations that you want to move along with the identifier. When you move an identifier that has a related comment section, the move refactoring moves the comment section along with the identifier.  |
| To directory |  Specify the directory that will store the selected identifiers.  |
| To file |  Specify the name of the file that will store the selected declarations.  |
| To package |  Specify a name of a package that will store the selected identifiers.  |
| Refactor |  Click the button to start the move refactoring.  |
| Preview |  Click the button to preview all the changes that you are about to perform in the Find  tool window.  |
| Cancel |  Click the button to cancel the move refactoring.  |

