GoLand
 
Get GoLand
Because GoLand 2025.1 is still in development, this documentation may not be entirely accurate and is subject to change.

Extract method

Last modified: 14 February 2025

With the Extract Method refactoring, you can take a code fragment, move it into a separated method and replace the old code with a call to the method. If the code always exits in return statements (all execution paths lead to possibly implicit return statements), it is extracted as is. However, if it contains execution paths without returns, the extracted method will have an additional bool flag as a return value. The flag is used to perform an early return on the call side.

When you extract a function by using the Extract Method refactoring, GoLand keeps the original order of parameters of a parent function.