GoLand
 
Get GoLand
You are viewing the documentation for an earlier version of GoLand.

Introduce type

Last modified: 08 March 2021

The Introduce Type refactoring extracts a type that is inside of another type. Also, you can use this refactroing for converting the anonymous structure type to a named type.

For example, the extract operation might look like this. Consider the following JSON.

If you paste it to GoLand's editor and convert it to a struct type, you will get the T struct type with another Location struct type inside. The T struct is valid and you can continue working with it. But you might want to embed the Location type differently. See the following animation.

https://resources.jetbrains.com/help/img/idea/2023.2/go_extract_type_refactoring.png
Gif