Using the move refactoring
With the move refactoring, you can take any top-level named identifier from your code and move it either to a separate file or to a different package.
For example purposes, clone the Delve project from Github: git clone https://github.com/derekparker/delve. For more information about Git, refer to the official Git documentation.
Move a function declaration to a new file
Open the Delve project in GoLand.
Navigate to .
Right-click the
SplitQuotedFieldsfunction declaration and select . Alternatively, press F6.In the To file field, type
newsplit.Click Refactor. The newsplit.go file is created with the function that we moved. The move refactoring does not only move declarations, but also adds the required imports, updates the references to the identifier, and performs a cleanup of the previous definition place of the identifier so that your code can still work.

Preview changes before the refactoring
Open the Delve project in GoLand.
Navigate to .
Right-click the
GoVersiontype and select . Alternatively, press F6.Specify a file path and a file name. For example, add
/goverto the file path in the To directory field, and typegoverin the To file field.Select
AfterOrEqualandIsDevelidentifiers for theGoVersiontype. GoLand displays a notification when the identifier is private and is not exported during the move operation.Click Preview. In the Find tool window, you can review refactoring changes and exclude Delete or remove Ctrl+X code parts from the refactoring process.
