# Code refactoring

> For the complete documentation index, see [llms.txt](https://www.jetbrains.com/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.

<a id="refactoring_invoke"></a>

## Invoke refactoring

<a id="invoke-refactoring-procedure"></a>

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 [Refactor This… shortcut](https://www.jetbrains.com/help/go/llms-keymap-index.md "Refactorings.QuickListPopupAction") 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 [Undo shortcut](https://www.jetbrains.com/help/go/llms-keymap-index.md "$Undo").

<a id="refactoring_preview"></a>

## Preview refactoring changes

<a id="changes_preview"></a>

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 shortcut](https://www.jetbrains.com/help/go/llms-keymap-index.md "$Delete") or remove [Cut shortcut](https://www.jetbrains.com/help/go/llms-keymap-index.md "$Cut") changes that you consider unnecessary.

3. Click Do Refactor to proceed with the changes.

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

<a id="refactoring_conflicts"></a>

## Resolve conflicts

<a id="resolve-conflicts-procedure"></a>

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/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.

<a id="refactoring_settings"></a>

## Configure refactoring settings

<a id="config_refactor_settings"></a>

Procedure: Configure refactoring settings

1. In the Settings dialog ([Settings… shortcut](https://www.jetbrains.com/help/go/llms-keymap-index.md "ShowSettings")), select `Editor | Code Editing`.

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

<a id="popular-refactorings"></a>

## The most popular refactorings supported in GoLand

|  Safe Delete  |  [Safe Delete… shortcut](https://www.jetbrains.com/help/go/llms-keymap-index.md "SafeDelete")  | Makes sure that you do not delete files that are referenced in your source code.  |  [Safe delete](https://www.jetbrains.com/help/go/safe-delete.html.md)  |
| Copy/Move | [Copy… shortcut](https://www.jetbrains.com/help/go/llms-keymap-index.md "CopyElement")/ [Move… shortcut](https://www.jetbrains.com/help/go/llms-keymap-index.md "Move")  | Copies/Moves an element. |  [Copy and move refactorings](https://www.jetbrains.com/help/go/move-refactorings.html.md)  |
| Extract Method |  [Extract Method… shortcut](https://www.jetbrains.com/help/go/llms-keymap-index.md "ExtractMethod")  | These refactoring actions help you reduce the code duplication.  |  [Extract method](https://www.jetbrains.com/help/go/extract-method.html.md)  |
| Extract Constant |  [Introduce Constant… shortcut](https://www.jetbrains.com/help/go/llms-keymap-index.md "IntroduceConstant")  |    |  [Extract constant](https://www.jetbrains.com/help/go/extract-constant.html.md)  |
|  Introduce Variable  |  [Introduce Variable… shortcut](https://www.jetbrains.com/help/go/llms-keymap-index.md "IntroduceVariable")  |    |  [Extract/Introduce variable](https://www.jetbrains.com/help/go/extract-variable.html.md)  |
| Rename |  [Rename… shortcut](https://www.jetbrains.com/help/go/llms-keymap-index.md "RenameElement")  | Renames an element. |  [Rename refactorings](https://www.jetbrains.com/help/go/rename-refactorings.html.md)  |
| Inline |  [Inline… shortcut](https://www.jetbrains.com/help/go/llms-keymap-index.md "Inline")  | Inlines an element. Acts as the opposite of extracting. |  [Inline](https://www.jetbrains.com/help/go/inline.html.md)  |
| Change signature |  [Change Signature… shortcut](https://www.jetbrains.com/help/go/llms-keymap-index.md "ChangeSignature")  | Changes the call signature of a method or class.  |  [Change signature](https://www.jetbrains.com/help/go/change-signature.html.md)  |

## 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/)

