# Code refactoring

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

[Refactoring](https://en.wikipedia.org/wiki/Code_refactoring) is a process of improving your source code without creating a new functionality. Refactoring helps you keep your code solid , [dry](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself),  and easy to maintain.

## Invoke refactoring

Procedure: Invoke refactoring

1. Select an item to refactor. You can select a file/folder in the Project tool window or expression/symbol in the editor.

2. Press `Ctrl+Alt+Shift+T` (Windows), `⌃ T` (macOS), `⌘ ⌥ ⇧ T` (IntelliJ IDEA Classic (macOS)), `⌃ S` (macOS System Shortcuts), `Ctrl+Alt+Shift+T` (XWin), `Ctrl+Alt+Shift+T` (GNOME), `Ctrl+Alt+Shift+T` (KDE), `Ctrl+Alt+Shift+T` (Emacs), `Ctrl+Alt+Shift+T` (Sublime Text), `⌃ T` (Sublime Text (macOS)), `Ctrl+Shift+R` (VSCode), `⌃ ⇧ R` (VSCode (macOS)) to open a list of refactorings that can be selected.

Alternatively, you can use a keyboard shortcut for a specific refactoring.

If you need to undo your 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)).

## Preview refactoring changes

Procedure: Preview refactoring changes

For some refactorings, GoLand lets you preview the changes before applying them.

1. Click Preview in the Refactoring Preview dialog to see potential changes (the list of usages where the refactoring will be performed).

2. In the  Find tool window   tool window that opens, check the changes that are going to be made. You can exclude `Delete` (Windows), `⌦` (macOS), `⌦` (IntelliJ IDEA Classic (macOS)), `⌦` (macOS System Shortcuts), `Delete` (XWin), `Delete` (GNOME), `Delete` (KDE), `Delete` (Emacs), `Delete` (Sublime Text), `⌦` (Sublime Text (macOS)), `Delete` (VSCode), `⌦` (VSCode (macOS)) or remove `Ctrl+X` (Windows), `⌘ X` (macOS), `⌘ X` (IntelliJ IDEA Classic (macOS)), `⌘ X` (macOS System Shortcuts), `Ctrl+X` (XWin), `Ctrl+X` (GNOME), `Ctrl+X` (KDE), `Shift+Delete` (Emacs), `Ctrl+X` (Sublime Text), `⌘ X` (Sublime Text (macOS)), `Ctrl+X` (VSCode), `⌘ X` (VSCode (macOS)) changes that you consider unnecessary.

3. Click Do Refactor to proceed with the changes.

![The Preview changes window](https://resources.jetbrains.com.cn/help/img/idea/2026.3/go_preview_changes.png)

## Resolve conflicts

Procedure: Resolve conflicts

When GoLand encounters problems with your refactoring, it opens a dialog with the list of conflicts and their brief descriptions.

![Refactoring conflicts dialog](https://resources.jetbrains.com.cn/help/img/idea/2026.3/go_refactoring_conflicts_dialog.png)

* Click Refactor Anyway to ignore the problem and proceed.

* Click Open in Find Window to open the conflict entries in the Find tool window and deal with them further.

* In the Find tool window, you can apply the refactor by selecting Refactor or click Cancel and return to the editor.

## Configure refactoring settings

Procedure: Configure refactoring settings

1. In the Settings dialog (`Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Comma` (VSCode), `⌘ Comma` (VSCode (macOS))), select `Editor | Code Editing`.

2. On the Code Editing page, in the Refactorings section, adjust the refactoring options and click OK.

## The most popular refactorings supported in GoLand

|  Safe Delete  |  `Alt+Delete` (Windows), `⌘ ⌦` (macOS), `⌘ ⌦` (IntelliJ IDEA Classic (macOS)), `⌘ ⌦` (macOS System Shortcuts), `Alt+Delete` (XWin), `Alt+Delete` (GNOME), `Alt+Delete` (KDE), `Alt+Delete` (Emacs), `Alt+Delete` (Sublime Text), `⌘ ⌦` (Sublime Text (macOS)), `Alt+Delete` (VSCode), `Alt+Delete` (VSCode (macOS))  | Makes sure that you do not delete files that are referenced in your source code.  |  [Safe delete](safe-delete.html)  |
| Copy/Move | `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))/ `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))  | Copies/Moves an element. |  [Copy and move refactorings](move-refactorings.html)  |
| Extract Method |  `Ctrl+Alt+M` (Windows), `⌘ ⌥ M` (macOS), `⌘ ⌥ M` (IntelliJ IDEA Classic (macOS)), `⌘ ⌥ M` (macOS System Shortcuts), `Ctrl+Alt+M` (XWin), `Ctrl+Alt+M` (GNOME), `Ctrl+Alt+M` (KDE), `Ctrl+Alt+M` (Emacs), `Ctrl+Alt+M` (Sublime Text), `⌘ ⌥ M` (Sublime Text (macOS)), `Ctrl+Alt+M` (VSCode), `⌘ ⌥ M` (VSCode (macOS))  | These refactoring actions help you reduce the code duplication.  |  [Extract method](extract-method.html)  |
| Extract Constant |  `Ctrl+Alt+C` (Windows), `⌘ ⌥ C` (macOS), `⌘ ⌥ C` (IntelliJ IDEA Classic (macOS)), `⌘ ⌥ C` (macOS System Shortcuts), `Ctrl+Alt+C` (XWin), `Ctrl+Alt+C` (GNOME), `Ctrl+Alt+C` (KDE), `Ctrl+Alt+C` (Emacs), `Ctrl+Alt+C` (Sublime Text), `⌘ ⌥ C` (Sublime Text (macOS)), `Ctrl+Alt+C` (VSCode), `Ctrl+Alt+C` (VSCode (macOS))  |    |  [Extract constant](extract-constant.html)  |
|  Introduce Variable  |  `Ctrl+Alt+V` (Windows), `⌘ ⌥ V` (macOS), `⌘ ⌥ V` (IntelliJ IDEA Classic (macOS)), `⌘ ⌥ V` (macOS System Shortcuts), `Ctrl+Alt+V` (XWin), `Ctrl+Alt+V` (GNOME), `Alt+Shift+V` (KDE), `Ctrl+Alt+V` (Emacs), `Ctrl+Alt+V` (Sublime Text), `Ctrl+Alt+V` (Sublime Text (macOS)), `Ctrl+Alt+V` (VSCode), `⌘ ⌥ V` (VSCode (macOS))  |    |  [Extract/Introduce variable](extract-variable.html)  |
| Rename |  `Shift+F6` (Windows), `⇧ F6` (macOS), `⇧ F6` (IntelliJ IDEA Classic (macOS)), `⌘ ⌥ R` (macOS System Shortcuts), `Shift+F6` (XWin), `Shift+F6` (GNOME), `Shift+F6` (KDE), `Shift+F6` (Emacs), `Shift+F6` (Sublime Text), `⇧ F6` (Sublime Text (macOS)), `F2` (VSCode), `F2` (VSCode (macOS))  | Renames an element. |  [Rename refactorings](rename-refactorings.html)  |
| Inline |  `Ctrl+Alt+N` (Windows), `⌘ ⌥ N` (macOS), `⌘ ⌥ N` (IntelliJ IDEA Classic (macOS)), `⌘ ⌥ N` (macOS System Shortcuts), `Ctrl+Alt+N` (XWin), `Ctrl+Alt+N` (GNOME), `Ctrl+Alt+N` (KDE), `Ctrl+Alt+N` (Emacs), `Ctrl+Alt+N` (Sublime Text), `⌘ ⌥ N` (Sublime Text (macOS)), `Ctrl+Alt+N` (VSCode), `⌘ ⌥ N` (VSCode (macOS))  | Inlines an element. Acts as the opposite of extracting. |  [Inline](inline.html)  |
| Change signature |  `Ctrl+F6` (Windows), `⌘ F6` (macOS), `⌘ F6` (IntelliJ IDEA Classic (macOS)), `⌘ ⌥ S` (macOS System Shortcuts), `Ctrl+F6` (XWin), `Ctrl+F6` (GNOME), `Ctrl+6` (KDE), `Ctrl+F6` (Emacs), `Ctrl+F6` (Sublime Text), `Ctrl+F6` (Sublime Text (macOS)), `Ctrl+F6` (VSCode), `⌘ F6` (VSCode (macOS))  | Changes the call signature of a method or class.  |  [Change signature](change-signature.html)  |

## See also

### External Links

[http://www.refactoring.com/](http://www.refactoring.com/)

### Web Resources

[Refactoring](https://blog.jetbrains.com/go/2018/03/20/goland-2018-1-public-preview/)

