Extract Type Refactoring

Extract a type into its own definition and improve the reusability in your code.

If you have an anonymous type defined, you can extract it into a standalone type and reuse it across your code.

Invoke Refactor this with ^T (macOS) / Ctrl+Alt+Shift+T (Windows/Linux), on the anonymous type, then select the Extract type from the list of available refactorings.

Give it a name and start reusing the newly created type in your code.


Related Resources

Rename a File and its References
Rename a File and its References
Change your mind on a file name, and the IDE makes all the changes for you.
Rename Go Module Refactoring
Rename Go Module Refactoring
Upgrade Go modules to newer versions with ease
Create a Function in Another Package
Create a Function in Another Package
Type a non-existing function name and generate its implementation in a package of your choice.